com.jimuwd.xian.registry-proxy 1.0.76 → 1.0.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +4 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -209,22 +209,19 @@ async function writeResponseToDownstreamClient(registryInfo, targetUrl, resToDow
|
|
|
209
209
|
else {
|
|
210
210
|
// write back to client
|
|
211
211
|
resToDownstreamClient.writeHead(upstreamResponse.status, safeHeaders);
|
|
212
|
-
//
|
|
212
|
+
// stop pipe when req from client is closed accidentally.
|
|
213
213
|
const cleanup = () => {
|
|
214
214
|
reqFromDownstreamClient.off('close', cleanup);
|
|
215
|
-
logger.
|
|
215
|
+
logger.info(`Req from downstream client is closed, stop pipe from upstream ${targetUrl} to downstream client.`);
|
|
216
216
|
upstreamResponse.body?.unpipe();
|
|
217
|
-
resToDownstreamClient.destroy();
|
|
218
|
-
reqFromDownstreamClient.destroy();
|
|
219
217
|
};
|
|
220
218
|
reqFromDownstreamClient.on('close', cleanup);
|
|
219
|
+
reqFromDownstreamClient.on('end', () => logger.info("Req from downstream client ends."));
|
|
221
220
|
// clean up when server closes connection to downstream client.
|
|
222
221
|
const cleanup0 = () => {
|
|
223
222
|
resToDownstreamClient.off('close', cleanup0);
|
|
224
223
|
logger.info(`Close connection to downstream client, upstream url is ${targetUrl}`);
|
|
225
|
-
|
|
226
|
-
// resToDownstreamClient.destroy();
|
|
227
|
-
// reqFromDownstreamClient.destroy();
|
|
224
|
+
upstreamResponse.body?.unpipe();
|
|
228
225
|
};
|
|
229
226
|
resToDownstreamClient.on('close', cleanup0);
|
|
230
227
|
// write back body data (chunked probably)
|