Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions .pnp.loader.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions .yarn/versions/9a6615ad.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
releases:
"@yarnpkg/cli": patch
"@yarnpkg/plugin-pnp": patch
"@yarnpkg/pnp": patch

declined:
- "@yarnpkg/plugin-compat"
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-nm"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnpm"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-version"
- "@yarnpkg/plugin-workspace-tools"
- "@yarnpkg/builder"
- "@yarnpkg/core"
- "@yarnpkg/doctor"
- "@yarnpkg/nm"
- "@yarnpkg/pnpify"
- "@yarnpkg/sdks"
2 changes: 1 addition & 1 deletion packages/yarnpkg-pnp/sources/esm-loader/built-loader.js

Large diffs are not rendered by default.

30 changes: 21 additions & 9 deletions packages/yarnpkg-pnp/sources/esm-loader/fspatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,29 @@ if (!HAS_LAZY_LOADED_TRANSLATORS) {

const originalReadFile = binding.readFileUtf8 || binding.readFileSync;
if (originalReadFile) {
// `fs.readFileSync` calls back into this binding for files that aren't
// in a zip archive, which would recurse until the stack overflows (and
// the `RangeError` would be swallowed by the `catch` below). Nested calls
// go straight to the original binding instead.
let isInPatchedReadFile = false;

// @ts-expect-error - No index signature
binding[originalReadFile.name] = function (...args: Parameters<typeof originalReadFile>) {
try {
return fs.readFileSync(args[0], {
encoding: `utf8`,
// @ts-expect-error - The docs says it needs to be a string but
// links to https://nodejs.org/dist/latest-v20.x/docs/api/fs.html#file-system-flags
// which says it can be a number which matches the implementation.
flag: args[1],
});
} catch { }
if (!isInPatchedReadFile) {
isInPatchedReadFile = true;
try {
return fs.readFileSync(args[0], {
encoding: `utf8`,
// @ts-expect-error - The docs says it needs to be a string but
// links to https://nodejs.org/dist/latest-v20.x/docs/api/fs.html#file-system-flags
// which says it can be a number which matches the implementation.
flag: args[1],
});
} catch {
} finally {
isInPatchedReadFile = false;
}
}

return originalReadFile.apply(this, args);
};
Expand Down
Loading