Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
not-an-aardvark opened this issue Mar 2, 2017 · 4 comments

Comments

@not-an-aardvark
Copy link
Contributor

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 nodejs/node#11522.

@straker
Copy link

straker commented Mar 2, 2017

+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
Copy link
Contributor Author

I made a PR to fix this in #198.

@straker
Copy link

straker commented Mar 13, 2017

That fixed my problem. Thanks!

@tschaub
Copy link
Owner

tschaub commented Mar 13, 2017

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

Slayer95 pushed a commit to Slayer95/mock-fs that referenced this issue Apr 27, 2017
…haub#197)

Node 7.7 changed the behavior of the `binding.{stat,lstat,fstat}` functions (see nodejs/node#11522). This updates the binding functions used in mock-fs to match the new Node binding behavior, while still maintaining compatibility with old Node versions. The new behavior is detected when the second argument to `binding.{stat,lstat,fstat}` is a `Float64Array`, which would be an invalid argument for previous versions of the binding.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants