[Bug] `fs` patch doesn't handle `{ bigint: true }`
See original GitHub issue- 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
Issue Analytics
- State:
- Created 3 years ago
- Reactions:14
- Comments:19 (7 by maintainers)
Top Results From Across the Web
Top 10 Most Common Node.js Developer Mistakes - Toptal
Mistake #6: Throwing Errors from Inside Callbacks. JavaScript has the notion of exceptions. Mimicking the syntax of almost all traditional languages with ...
Read more >How do I resolve "Cannot find module" error using Node.js?
Using npm install installs the module into the current directory only (in a subdirectory called node_modules ). Is app.js located under ...
Read more >File system | Node.js v19.3.0 Documentation
When operating on file handles, the mode cannot be changed from what it was set to with ... bigint <boolean> Whether the numeric...
Read more >BigInt: Arbitrary precision integers in JavaScript
Number must be used. The BigInt can however be concatenated with a String . For this reason, it is recommended to continue using...
Read more >BigInt - JavaScript - MDN Web Docs
BigInt values are similar to Number values in some ways, but also differ in a few key matters: A BigInt value cannot be...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Hashnode Post
No results found
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?