tschaub / mock-fs

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

Error when using mock-fs #374

Open lyqht opened 1 year ago

lyqht commented 1 year ago

I'm getting an error when using Node version v18.14.2, and trying to test a code that uses fs.readFile,fs.readFileSync, fs.existsSync, fs.writeFileSync, fs.writeFile

The error

(node:72471) Warning: File descriptor 5 closed but not opened in unmanaged mode
(Use `node --trace-warnings ...` to show where the warning was created)
stdout | unknown test
[Error: EBADF: bad file descriptor, read] {
  errno: -9,
  code: 'EBADF',
  syscall: 'read'
}

I don't quite understand the error, how do I fix this?

baob commented 1 year ago

Was this an intermittent error, or consistent ?

I'm seeing intermittent errors like this on node 14.21.3 - x64 and mock-fs@4.14.0. Examples

    EAGAIN: resource temporarily unavailable, read
    EBADF: bad file descriptor, read

It might not be the same problem ... apologies if so.

lyqht commented 1 year ago

It's a consistent error for me.

baob commented 1 year ago

Upgrading to latest mock-fs cured the flakiness for me.