tschaub / mock-fs

Configurable mock for the fs module
https://npmjs.org/package/mock-fs
Other
906 stars 86 forks source link

Uncaught error on Node.js 18.7: `Cannot mix BigInt and other types, use explicit conversions` #359

Closed AlCalzone closed 2 years ago

AlCalzone commented 2 years ago

My tests using mock-fs are failing with an unhandled error since upgrading from Node.js 18.6 to 18.7:

TypeError: Cannot mix BigInt and other types, use explicit conversions
 ❯ FSReqCallback.oncomplete node:fs:212:13
 ❯ node_modules/mock-fs/lib/binding.js:74:9

I've narrowed it down to (probably) being a restore() call. To reproduce:

  1. Install Node.js 18.7
  2. clone https://github.com/AlCalzone/jsonl-db
  3. git checkout 8407b733092e32bf5fb56337c59208665eab32e1
  4. npm run test:ts
justin-creighton commented 2 years ago

confirmed

3cp commented 2 years ago

nodejs v18.7.0 made another internal change.

The bigint stats now uses BigInt64Array, previously it was BigUint64Array (we are using this type to create bigint stats).

I will do some more tests and find a clear patch to work against all supported nodejs versions.

https://github.com/nodejs/node/commit/100f6deb09bd5b74dd977f476d5bd6fc626c3190

AlCalzone commented 2 years ago

Great, thanks for the quick fix!