com.jimuwd.xian.registry-proxy 1.0.69 → 1.0.71

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 +10 -2
  2. 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 {
@@ -200,7 +203,7 @@ async function writeResponseToDownstreamClient(registryInfo, targetUrl, resToDow
200
203
  else {
201
204
  // 二进制流处理
202
205
  if (!upstreamResponse.body) {
203
- logger.error(`Empty response body from ${targetUrl}`);
206
+ logger.error(`Empty response body from upstream ${targetUrl}`);
204
207
  resToDownstreamClient.writeHead(502).end('Empty Upstream Response');
205
208
  }
206
209
  else {
@@ -218,7 +221,7 @@ async function writeResponseToDownstreamClient(registryInfo, targetUrl, resToDow
218
221
  // clean up when server closes connection to downstream client.
219
222
  const cleanup0 = () => {
220
223
  resToDownstreamClient.off('close', cleanup0);
221
- logger.info(`Close connection to downstream client, destroy connection, upstream url is ${targetUrl}`);
224
+ logger.info(`Close connection to downstream client, upstream url is ${targetUrl}`);
222
225
  /*upstreamResponse.body?.unpipe(); 代理服务器主动关闭与客户端的连接,不需要此时对接管道已经断开了,没必要重复断开*/
223
226
  // resToDownstreamClient.destroy();
224
227
  // reqFromDownstreamClient.destroy();
@@ -335,6 +338,11 @@ export async function startProxyServer(proxyConfigPath, localYarnConfigPath, glo
335
338
  logger.error('Server error:', err);
336
339
  reject(err);
337
340
  });
341
+ server.on('connection', (socket) => {
342
+ logger.debug("Server on connection");
343
+ socket.setTimeout(60000);
344
+ socket.setKeepAlive(true, 30000);
345
+ });
338
346
  server.listen(port, () => {
339
347
  const address = server.address();
340
348
  proxyPort = address.port;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.jimuwd.xian.registry-proxy",
3
- "version": "1.0.69",
3
+ "version": "1.0.71",
4
4
  "description": "A lightweight npm registry proxy with fallback support",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",