You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot read properties of undefined (reading 'filename') #258
This is caused by a change in the internal implementation of Gunzip in fflate. The code here seems to assume that one chunk in produces one chunk out with Gunzip, but this is not a guarantee of the API and was only an implementation detail of earlier versions of fflate. v0.8.3 introduced changes that may produce multiple output chunks for each input chunk, which caused things to break here.
This patch fixes the issue:
diff --git a/node_modules/@arethetypeswrong/core/dist/createPackage.js b/node_modules/@arethetypeswrong/core/dist/createPackage.js
index 1b8fb1c..68d1492 100644
--- a/node_modules/@arethetypeswrong/core/dist/createPackage.js+++ b/node_modules/@arethetypeswrong/core/dist/createPackage.js@@ -11,7 +11,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
};
var _Package_files;
import { untar } from "@andrewbranch/untar.js";
-import { Gunzip } from "fflate";+import { Gunzip, FlateErrorCode } from "fflate";
import { major, maxSatisfying, minor, valid, validRange } from "semver";
import ts from "typescript";
import { parsePackageSpec } from "./utils.js";
@@ -224,8 +224,21 @@ export function createPackageFromTarballData(tarball) {
function extractTarball(tarball) {
var _a;
// Use streaming API to work around https://github.com/101arrowz/fflate/issues/207
- let unzipped;- new Gunzip((chunk) => (unzipped = chunk)).push(tarball, /*final*/ true);+ const chunks = [];+ try {+ new Gunzip((chunk) => chunks.push(chunk)).push(tarball, /*final*/ true);+ } catch (err) {+ // this happens for zero-padded tarballs; can safely ignore+ if (err.code != FlateErrorCode.InvalidHeader) {+ throw err;+ }+ }+ const unzipped = new Uint8Array(chunks.reduce((a, b) => a + b.length, 0));+ let offset = 0;+ for (const chunk of chunks) {+ unzipped.set(chunk, offset);+ offset += chunk.length;+ }
const data = untar(unzipped);
const prefix = data[0].filename.substring(0, data[0].filename.indexOf("/") + 1);
const packageJsonText = (_a = data.find((f) => f.filename === `${prefix}package.json`)) === null || _a === void 0 ? void 0 : _a.fileData;
You should be able to do something similar in the TypeScript source to fix the issue!
You may also be able to switch the implementation to const unzipped = gunzipSync(tarball);. That will work for any package without zero-padding at the end of the npm tarball (which seems to be rare/a bug).
Reacted by Mark, Andrew Kazakov, Eric Mika, Zishan Khan, Arya Emami, Vincent Driessen, earshinov and Andrew Branch
hi folks, I banged my head against walls and AIs and found nothing working for my project, as I cannot just install the cli in devDependencies, which will override one of my existing dependencies. Do you think pinpointing fflate to 0.8.2 in packages/core/package.json then releasing new minor update can mitigate this issue? I run so sick of the issue today 😅 😤
@andrewbranch using ^ for zero versions is just asking for trouble. Per the semver spec, any public API may change at any time between 0.x.y versions.
Also, I would rather see this use a more stable compression library that's >= 1.0.0 instead of an unstable library just because it hypes its size and speed.
@andrewbranch it would be good to check if the array returned by untar is empty and print a better error message in that case, because a tarball that happens to be empty for some reason would also cause this "Cannot read properties of undefined" error message. It would probably also be good to print a warning if there are garbage entries after the zero block in the archive, or if the last record is shorter than the rest.
Activity
101arrowz commentedon May 16, 2026
This is caused by a change in the internal implementation of
Gunzipinfflate. The code here seems to assume that one chunk in produces one chunk out withGunzip, but this is not a guarantee of the API and was only an implementation detail of earlier versions offflate. v0.8.3 introduced changes that may produce multiple output chunks for each input chunk, which caused things to break here.This patch fixes the issue:
You should be able to do something similar in the TypeScript source to fix the issue!
You may also be able to switch the implementation to
const unzipped = gunzipSync(tarball);. That will work for any package without zero-padding at the end of the npm tarball (which seems to be rare/a bug).PineBale commentedon May 16, 2026
PerryFinn commentedon May 17, 2026
I encountered the same problem
PineBale commentedon May 17, 2026
hi folks, I banged my head against walls and AIs and found nothing working for my project, as I cannot just install the cli in devDependencies, which will override one of my existing dependencies. Do you think pinpointing fflate to 0.8.2 in
packages/core/package.jsonthen releasing new minor update can mitigate this issue? I run so sick of the issue today 😅 😤jedwards1211 commentedon May 18, 2026
@andrewbranch using ^ for zero versions is just asking for trouble. Per the semver spec, any public API may change at any time between 0.x.y versions.
Also, I would rather see this use a more stable compression library that's >= 1.0.0 instead of an unstable library just because it hypes its size and speed.
fix(@arethetypeswrong/core): pin fflate to 0.8.2
fix: pin `fflate` to 0.8.2
fix: pin `fflate` to 0.8.2
jedwards1211 commentedon May 19, 2026
@andrewbranch it would be good to check if the array returned by
untaris empty and print a better error message in that case, because a tarball that happens to be empty for some reason would also cause this "Cannot read properties of undefined" error message. It would probably also be good to print a warning if there are garbage entries after the zero block in the archive, or if the last record is shorter than the rest.Drop attw from CI and prepublishOnly, add publishConfig.access
Rename package to @florent-uzio/custody for npm publish (#123)
polRk commentedon May 19, 2026
Just link https://github.com/ydb-platform/ydb-js-sdk/actions/runs/26124331076/job/76834047480?pr=609
earshinov commentedon May 21, 2026
@101arrowz , thanks for the patch. Checked it locally -- seems to be working fine. Submitted PR #261
attwbroken by[email protected]- tarball extraction keeps only the empty final-flush chunk #262 as a duplicate of this issueci: pin [email protected] to fix attw type-resolution check
18 remaining items
chore: update `@arethetypeswrong/cli` to `0.18.3` to fix CI failure
chore: update `@arethetypeswrong/cli` to `0.18.3` to fix CI failure
chore: update `@arethetypeswrong/cli` to `0.18.3` to fix CI failure
chore: update `@arethetypeswrong/cli` to `0.18.3` to fix CI failure
chore: update `@arethetypeswrong/cli` to `0.18.3` to fix CI failure (#…
fix: pin `fflate` to 0.8.2
fix: pin `fflate` to 0.8.2
fix: pin `fflate` to 0.8.2
fix: pin `fflate` to 0.8.2
fix: pin `fflate` to 0.8.2
fix: pin `fflate` to 0.8.2
pin fflate
bump: npm upgrade (#1058)
build(client): update @arethetypeswrong/cli to 0.18.5 (#27961)
chore(deps): drop the fflate override; attw 0.18.5