berry: [Bug] `fs` patch doesn't handle `{ bigint: true }`
- I’d be willing to implement a fix
Describe the bug
When running on Node 15.4.0, the following error can occur:
node:fs:1931
const dev = BigIntPrototypeToString(stats.dev, 32);
^
TypeError: BigInt.prototype.toString requires that 'this' be a BigInt
at Number.toString (<anonymous>)
at gotStat (node:fs:1931:19)
This started happening because of this commit: https://github.com/nodejs/node/blob/8d6c2f2ada79e52ec0b376769a7d94814945bd4f/lib/fs.js#L1931
The root cause is that the fake fs
implementation doesn’t correctly handle the { bigint: true }
option that the various fs.stat
functions can take:
https://nodejs.org/api/fs.html#fs_class_fs_stats
To Reproduce
$ nvm install 15.4.0
$ yarn init -2
update package.json to:
{
"name": "bug",
"scripts": {
"start": "echo test",
"bug": "yarn bug"
}
}
$ yarn
$ yarn bug
➜ yarn bug
node:fs:1931
const dev = BigIntPrototypeToString(stats.dev, 32);
^
TypeError: BigInt.prototype.toString requires that 'this' be a BigInt
at Number.toString (<anonymous>)
at gotStat (node:fs:1931:19)
at /private/var/folders/j7/mjhkhz7x15z0nmt42b5k2x980000gn/T/tmp.K9NgZraS/.pnp.js:4516:13
Screenshots
If applicable, add screenshots to help explain your problem.
Environment if relevant (please complete the following information):
- OS: OSX
- Node version 15.4.0
- Yarn version 2.4.0
Additional context
https://discord.com/channels/226791405589233664/226793713722982400/786920513238073395
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 14
- Comments: 19 (7 by maintainers)
Commits related to this issue
- Fix Yarn 2 fs patch BigInt bug Yarn 2 has this bug with Node 15. The bug is fixed in a branch that hasn't been published yet. The choice was between `yarn set version from sources --branch 2262` and ... — committed to MartinRosenberg/typescript-exercises by MartinRosenberg 3 years ago
- upgrade yarn to patched version to solve https://github.com/yarnpkg/berry/issues/2232 — committed to fullcalendar/fullcalendar by arshaw 3 years ago
- chore: upgrade yarn to 3.0.0-rc.2 workaround https://github.com/yarnpkg/berry/issues/2232 — committed to babel/babel-loader by JLHwung 3 years ago
I can confirm that #2262 fixes it. It can be used via:
Make sure to run
yarn install
afterwards.Any chance of this getting ported into the 2.4 branch or will it only ship in 3.0?
Since it has been merged
master
would be the most up to dateYes, see https://github.com/yarnpkg/berry/issues/2232#issuecomment-752052924
Same problem with yarn 2.4.0 (zero install) and ts-node-dev.
Environment:
OS: OSX
Code: https://github.com/avevlad/ts-data-analysis-with-zero-install/tree/39223a836097ded6201592364b925798c0fddea5
The 2.4.1 only includes a TS compat fix. It’ll be part of the 3.0, which takes a bit of time due to me being on vacation at the moment - will release when I’m back.
@arcanis Odd, I’m still getting this issue with the latest yarn (2.4.1), even though it’s been released only few weeks ago, and the PR was merged in December. Maybe the relevant packages weren’t upgraded in the release?