com.jimuwd.xian.registry-proxy 1.1.18 → 1.1.20-beta01

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.
@@ -128,8 +128,8 @@ async function main() {
128
128
  console.log(`Set npmRegistryServer to http://127.0.0.1:${PROXY_PORT}`);
129
129
  registerCleanup(async () => {
130
130
  try {
131
- await execa('yarn', ['config', 'unset', 'npmRegistryServer']);
132
- console.log('Cleared npmRegistryServer configuration');
131
+ await execa('yarn', ['config', 'unset', 'npmRegistryServer']); //fixme:这里使用unset,有个缺点就是如果工程中.yarnrc.yml原本配置的只读registryServer没有恢复而是被清空了!国内的网络再执行任何拉取操作或yarn dlx命令容易超时!
132
+ console.log('Cleared npmRegistryServer configuration:这里清空npmRegistryServer而不是恢复,有个缺点就是如果工程中.yarnrc.yml原本配置的只读registryServer没有恢复而是被清空了!国内的网络再执行任何拉取操作或yarn dlx命令容易超时!');
133
133
  }
134
134
  catch {
135
135
  }
@@ -199,21 +199,19 @@ async function _fetchFromRegistry(registry, targetUrl, reqFromDownstreamClient)
199
199
  }
200
200
  catch (e) {
201
201
  // Fetch form one of the configured upstream registries failed, this is expected behavior, not error.
202
- if (e instanceof Error) {
203
- const errCode = e.code;
204
- if (errCode === 'ECONNREFUSED') {
205
- logger.info(`Upstream ${targetUrl} refused connection [ECONNREFUSED], skip fetching from registry ${registry.normalizedRegistryUrl}`);
206
- }
207
- else if (errCode === 'ENOTFOUND') {
208
- logger.info(`Unknown upstream domain name in ${targetUrl} [ENOTFOUND], skip fetching from registry ${registry.normalizedRegistryUrl}.`);
209
- }
210
- else {
211
- // Other net error code, print log with stacktrace
212
- logger.warn(`Failed to fetch from ${targetUrl}, ${e.message}`, e);
213
- }
202
+ const errCode = e?.code;
203
+ if (errCode === 'ECONNREFUSED') {
204
+ logger.info(`Upstream ${targetUrl} refused connection [ECONNREFUSED], skip fetching from registry ${registry.normalizedRegistryUrl}`);
205
+ }
206
+ else if (errCode === 'ENOTFOUND') {
207
+ logger.info(`Unknown hostname in upstream url ${targetUrl} [ENOTFOUND], skip fetching from registry ${registry.normalizedRegistryUrl}.`);
208
+ }
209
+ else if (errCode === 'EAI_AGAIN') {
210
+ logger.info(`Could not resolve hostname in upstream url ${targetUrl} [EAI_AGAIN], skip fetching from registry ${registry.normalizedRegistryUrl}.`);
214
211
  }
215
212
  else {
216
- logger.error("Unknown error", e);
213
+ // Other net error code, print log with stacktrace
214
+ logger.warn(`Failed to fetch from ${targetUrl}`, e);
217
215
  }
218
216
  // Return null means skipping current upstream registry.
219
217
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.jimuwd.xian.registry-proxy",
3
- "version": "1.1.18",
3
+ "version": "1.1.20-beta01",
4
4
  "description": "A lightweight npm registry local proxy with fallback support",
5
5
  "type": "module",
6
6
  "main": "dist/server/index.js",