Skip to content

[Bug] fs patch doesn't handle { bigint: true } #2232

@andreialecu

Description

@andreialecu
  • 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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingupholdedReal issues without formal reproduction

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions