tschaub / mock-fs

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

Calling fs.statSync with an active mock causes an error in Node 7.7.1 #197

Closed not-an-aardvark closed 7 years ago

not-an-aardvark commented 7 years ago

Using mock-fs@4.1.0, Node 7.7.1

const mockFs = require('mock-fs');

mockFs({});

fs.statSync('foo')

This returns stats as expected, but then throws an error on the next tick.

Stats { ... }

> TypeError: callback is not a function
    at path/to/mock-fs/lib/binding.js:37:9
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickDomainCallback (internal/process/next_tick.js:128:9)

This is probably caused by https://github.com/nodejs/node/pull/11522.

straker commented 7 years ago

+1. Happens during normal file reading as well. I can't isolate to a particular event, but while looping over a list of files it just errors in the middle.

not-an-aardvark commented 7 years ago

I made a PR to fix this in #198.

straker commented 7 years ago

That fixed my problem. Thanks!

tschaub commented 7 years ago

Fix released in mock-fs@4.2. Thanks @not-an-aardvark.