com.jimuwd.xian.registry-proxy 1.0.45 → 1.0.47

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 CHANGED
@@ -7,7 +7,6 @@ import fetch from 'node-fetch';
7
7
  import { homedir } from 'os';
8
8
  import { join, resolve } from 'path';
9
9
  import { URL } from 'url';
10
- import { pipeline } from "node:stream/promises";
11
10
  const { readFile, writeFile } = fsPromises;
12
11
  class ConcurrencyLimiter {
13
12
  maxConcurrency;
@@ -176,7 +175,7 @@ async function writeSuccessfulResponse(registryInfo, targetUrl, res, response, r
176
175
  const headersToCopy = [
177
176
  'cache-control', 'etag', 'last-modified',
178
177
  'content-encoding', 'content-length',
179
- 'transfer-encoding', "collection"
178
+ 'transfer-encoding'
180
179
  ];
181
180
  headersToCopy.forEach(header => {
182
181
  const value = response.headers.get(header);
@@ -204,12 +203,13 @@ async function writeSuccessfulResponse(registryInfo, targetUrl, res, response, r
204
203
  }
205
204
  else {
206
205
  // 二进制流处理
207
- res.writeHead(response.status, safeHeaders);
208
206
  if (!response.body) {
209
207
  console.error(`Empty response body from ${targetUrl}`);
208
+ res.writeHead(response.status, safeHeaders).end();
210
209
  }
211
210
  else {
212
- await pipeline(response.body, res).finally(() => res.end());
211
+ res.writeHead(response.status, safeHeaders).end(response.body);
212
+ /*await pipeline(response.body, res).finally(() => res.end());*/
213
213
  }
214
214
  }
215
215
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.jimuwd.xian.registry-proxy",
3
- "version": "1.0.45",
3
+ "version": "1.0.47",
4
4
  "type": "module",
5
5
  "description": "A lightweight npm registry proxy with fallback support",
6
6
  "main": "dist/index.js",
package/src/index.ts CHANGED
@@ -241,7 +241,7 @@ async function writeSuccessfulResponse(
241
241
  const headersToCopy = [
242
242
  'cache-control', 'etag', 'last-modified',
243
243
  'content-encoding', 'content-length',
244
- 'transfer-encoding', "collection"
244
+ 'transfer-encoding'
245
245
  ];
246
246
 
247
247
  headersToCopy.forEach(header => {
@@ -270,11 +270,12 @@ async function writeSuccessfulResponse(
270
270
  res.end(JSON.stringify(data));
271
271
  } else {
272
272
  // 二进制流处理
273
- res.writeHead(response.status, safeHeaders);
274
273
  if (!response.body) {
275
274
  console.error(`Empty response body from ${targetUrl}`);
275
+ res.writeHead(response.status, safeHeaders).end();
276
276
  } else {
277
- await pipeline(response.body, res).finally(() => res.end());
277
+ res.writeHead(response.status, safeHeaders).end(response.body)
278
+ /*await pipeline(response.body, res).finally(() => res.end());*/
278
279
  }
279
280
  }
280
281
  } catch (err) {