com.jimuwd.xian.registry-proxy 1.0.63 → 1.0.65

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 +8 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -209,22 +209,24 @@ async function writeResponseToDownstreamClient(registryInfo, targetUrl, resToDow
209
209
  // stop transfer if client is closed accidentally.
210
210
  const cleanup = () => {
211
211
  downstreamReq.off('close', cleanup);
212
- logger.warn("Stop transfer when client is closed accidentally.");
212
+ logger.warn(`Downstream client closed accidentally, stop pipe from upstream ${targetUrl} to downstream client.`);
213
213
  upstreamResponse.body?.unpipe();
214
214
  };
215
215
  downstreamReq.on('close', cleanup);
216
216
  // write back body data (chunked probably)
217
- // pipe upstream body to downstream client and end when upstream ends.
218
- upstreamResponse.body.pipe(resToDownstreamClient, { end: true });
217
+ // pipe upstream body to downstream client
218
+ upstreamResponse.body.pipe(resToDownstreamClient, { end: false });
219
219
  upstreamResponse.body
220
- .on('data', (chunk) => logger.info(`chunk transferred size=${chunk.length}`))
220
+ .on('data', (chunk) => logger.info(`Chunk transferred from ${targetUrl} to downstream client size=${chunk.length}`))
221
221
  .on('end', () => {
222
- logger.info(`Upstream server ${registryInfo.normalizedRegistryUrl} response.body ended on url ${targetUrl}`);
222
+ logger.info(`Upstream server ${targetUrl} response.body ended.`);
223
+ resToDownstreamClient.end();
223
224
  })
224
225
  .on('close', () => {
225
- const errMsg = `Upstream server ${registryInfo.normalizedRegistryUrl} closed connection while transferring data on url ${targetUrl}`;
226
+ const errMsg = `Upstream server ${targetUrl} closed connection while transferring data.`;
226
227
  logger.error(errMsg);
227
228
  // resToDownstreamClient.destroy(new Error(errMsg));
229
+ resToDownstreamClient.destroy();
228
230
  })
229
231
  .on('error', (err) => {
230
232
  const errMsg = `Stream error: ${err.message}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.jimuwd.xian.registry-proxy",
3
- "version": "1.0.63",
3
+ "version": "1.0.65",
4
4
  "description": "A lightweight npm registry proxy with fallback support",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",