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.
- package/dist/index.js +8 -6
- 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(
|
|
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
|
|
218
|
-
upstreamResponse.body.pipe(resToDownstreamClient, { end:
|
|
217
|
+
// pipe upstream body to downstream client
|
|
218
|
+
upstreamResponse.body.pipe(resToDownstreamClient, { end: false });
|
|
219
219
|
upstreamResponse.body
|
|
220
|
-
.on('data', (chunk) => logger.info(`
|
|
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 ${
|
|
222
|
+
logger.info(`Upstream server ${targetUrl} response.body ended.`);
|
|
223
|
+
resToDownstreamClient.end();
|
|
223
224
|
})
|
|
224
225
|
.on('close', () => {
|
|
225
|
-
const errMsg = `Upstream server ${
|
|
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}`;
|