@vltpkg/registry-client 1.7.0 → 1.8.1

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/cache-entry.js +18 -6
  2. package/package.json +10 -10
@@ -36,6 +36,15 @@ const parseMaxUnpackedBytes = (raw) => {
36
36
  : defaultMaxUnpackedBytes;
37
37
  };
38
38
  const maxUnpackedBytes = parseMaxUnpackedBytes(process.env.VLT_TAR_MAX_UNPACKED_BYTES);
39
+ // same chunk sizing as @vltpkg/tar unpack: one output chunk, sized from
40
+ // the gzip trailer, within `max` and a cap (zlib reserves it up front)
41
+ const minChunk = 64 * 1024;
42
+ const maxChunk = 256 * 1024 * 1024;
43
+ const gzipChunkSize = (body, max) => {
44
+ const n = body.byteLength;
45
+ const isize = n < 4 ? 0 : (new DataView(body.buffer, body.byteOffset, n).getUint32(n - 4, true));
46
+ return Math.min(maxChunk, Math.max(minChunk, Math.min(isize + 1, max + 1)));
47
+ };
39
48
  const readSize = (buf, offset) => {
40
49
  const a = buf[offset];
41
50
  const b = buf[offset + 1];
@@ -523,21 +532,24 @@ export class CacheEntry {
523
532
  }
524
533
  // the body un-gzipped, for a body known to be gzipped
525
534
  #gunzip() {
526
- // we know that if we know it's gzip, that the body has been
527
- // flattened to a single buffer, so save the extra call.
535
+ // without a content-length, every _body read is a fresh concat
536
+ const body = this._body;
528
537
  /* c8 ignore start */
529
- if (this._body.length === 0)
538
+ if (body.length === 0)
530
539
  throw error('Invalid buffer, cant unzip');
531
540
  /* c8 ignore stop */
532
- const max = Math.min(maxUnpackedBytes, this._body.length * MAX_DECOMPRESSION_RATIO);
541
+ const max = Math.min(maxUnpackedBytes, body.length * MAX_DECOMPRESSION_RATIO);
533
542
  try {
534
- return gunzipSync(this._body, { maxOutputLength: max });
543
+ return gunzipSync(body, {
544
+ maxOutputLength: max,
545
+ chunkSize: gzipChunkSize(body, max),
546
+ });
535
547
  }
536
548
  catch (er) {
537
549
  throw (er.code ===
538
550
  'ERR_BUFFER_TOO_LARGE') ?
539
551
  error('cache entry exceeds maximum unpacked size', {
540
- found: this._body.length,
552
+ found: body.length,
541
553
  max,
542
554
  cause: er,
543
555
  })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vltpkg/registry-client",
3
3
  "description": "Fetch package artifacts and metadata from registries",
4
- "version": "1.7.0",
4
+ "version": "1.8.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/vltpkg/vltpkg.git",
@@ -13,15 +13,15 @@
13
13
  "url": "http://vlt.sh"
14
14
  },
15
15
  "dependencies": {
16
- "@vltpkg/cache": "1.7.0",
17
- "@vltpkg/cache-unzip": "1.7.0",
18
- "@vltpkg/error-cause": "1.7.0",
19
- "@vltpkg/keychain": "1.7.0",
20
- "@vltpkg/output": "1.7.0",
21
- "@vltpkg/types": "1.7.0",
22
- "@vltpkg/url-open": "1.7.0",
23
- "@vltpkg/user-agent": "1.7.0",
24
- "@vltpkg/xdg": "1.7.0",
16
+ "@vltpkg/cache": "1.8.1",
17
+ "@vltpkg/cache-unzip": "1.8.1",
18
+ "@vltpkg/error-cause": "1.8.1",
19
+ "@vltpkg/keychain": "1.8.1",
20
+ "@vltpkg/output": "1.8.1",
21
+ "@vltpkg/types": "1.8.1",
22
+ "@vltpkg/url-open": "1.8.1",
23
+ "@vltpkg/user-agent": "1.8.1",
24
+ "@vltpkg/xdg": "1.8.1",
25
25
  "cache-control-parser": "^2.0.6",
26
26
  "undici": "^7.16.0"
27
27
  },