com.jimuwd.xian.registry-proxy 1.0.70 → 1.0.72
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 +9 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -154,6 +154,9 @@ async function fetchFromRegistry(registry, targetUrl, limiter) {
|
|
|
154
154
|
? `Registry ${registry.normalizedRegistryUrl} unreachable [ECONNREFUSED]`
|
|
155
155
|
: `Error from ${registry.normalizedRegistryUrl}: ${e.message}`);
|
|
156
156
|
}
|
|
157
|
+
else {
|
|
158
|
+
logger.error("Unknown error", e);
|
|
159
|
+
}
|
|
157
160
|
return null;
|
|
158
161
|
}
|
|
159
162
|
finally {
|
|
@@ -195,12 +198,15 @@ async function writeResponseToDownstreamClient(registryInfo, targetUrl, resToDow
|
|
|
195
198
|
}
|
|
196
199
|
}
|
|
197
200
|
}
|
|
198
|
-
resToDownstreamClient.writeHead(upstreamResponse.status, { "content-type": contentType })
|
|
201
|
+
resToDownstreamClient.writeHead(upstreamResponse.status, { "content-type": contentType })
|
|
202
|
+
.end(JSON.stringify(data))
|
|
203
|
+
.destroy();
|
|
204
|
+
reqFromDownstreamClient.destroy();
|
|
199
205
|
}
|
|
200
206
|
else {
|
|
201
207
|
// 二进制流处理
|
|
202
208
|
if (!upstreamResponse.body) {
|
|
203
|
-
logger.error(`Empty response body from ${targetUrl}`);
|
|
209
|
+
logger.error(`Empty response body from upstream ${targetUrl}`);
|
|
204
210
|
resToDownstreamClient.writeHead(502).end('Empty Upstream Response');
|
|
205
211
|
}
|
|
206
212
|
else {
|
|
@@ -218,7 +224,7 @@ async function writeResponseToDownstreamClient(registryInfo, targetUrl, resToDow
|
|
|
218
224
|
// clean up when server closes connection to downstream client.
|
|
219
225
|
const cleanup0 = () => {
|
|
220
226
|
resToDownstreamClient.off('close', cleanup0);
|
|
221
|
-
logger.info(`Close connection to downstream client,
|
|
227
|
+
logger.info(`Close connection to downstream client, upstream url is ${targetUrl}`);
|
|
222
228
|
/*upstreamResponse.body?.unpipe(); 代理服务器主动关闭与客户端的连接,不需要此时对接管道已经断开了,没必要重复断开*/
|
|
223
229
|
// resToDownstreamClient.destroy();
|
|
224
230
|
// reqFromDownstreamClient.destroy();
|