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.
Files changed (2) hide show
  1. package/dist/index.js +4 -7
  2. 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
- // clean up when server if client is closed accidentally.
212
+ // stop pipe when req from client is closed accidentally.
213
213
  const cleanup = () => {
214
214
  reqFromDownstreamClient.off('close', cleanup);
215
- logger.warn(`Downstream client closed connection accidentally, stop pipe from upstream ${targetUrl} to downstream client.`);
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
- /*upstreamResponse.body?.unpipe(); 代理服务器主动关闭与客户端的连接,不需要此时对接管道已经断开了,没必要重复断开*/
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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.jimuwd.xian.registry-proxy",
3
- "version": "1.0.76",
3
+ "version": "1.0.77",
4
4
  "description": "A lightweight npm registry proxy with fallback support",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",