tschaub / mock-fs

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

fix: Replace nextTick by setImmediate. #360

Open regseb opened 2 years ago

regseb commented 2 years ago

Replace process.nextTick() by setImmediate() to be closer to the reality of asynchronous methods. This pull request fixes #352 testcase with yauzl.

3cp commented 2 years ago

The CI shows this fix only works for Nodejs v16+. You can try to add a condition to test against nodejs version.

regseb commented 2 years ago

I replaced the nextTick only for the promise and it seems to work on all versions of Node. Maybe the callbacks are executed directly after, while the promises are executed on the next event loop.

3cp commented 2 years ago

@tschaub can you review this? I am not sure about the side effect of this change.