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

fix: prepatch fs-binding to improve support nodejs v10+ readFile #265

Merged
merged 1 commit into from Apr 22, 2019
Merged

Conversation

3cp
Copy link
Collaborator

@3cp 3cp commented Apr 1, 2019

Changed strategy to prepatch fs-binding methods in order to bypass nodejs v10+'s direct binding method calling. As long as you do require('mock-fs') before using any fs method, the prepatch will work for nodejs v10+ readFile.
This new patch only works for ReadFileContext (used by fs.readFile), because its require is delayed (if (!ReadFileContext) ReadFileContext = require('internal/fs/read_file_context'))
Previous _writev patch is still required to bypass issue on WriteStream.

fixes #264, properly fixes #254

@3cp 3cp changed the title fix: prepatch fs-binding to improve support nodejs v10+ readFile WIP fix: prepatch fs-binding to improve support nodejs v10+ readFile Apr 1, 2019
Changed strategy to prepatch fs-binding methods in order to bypass nodejs v10+'s direct binding method calling. As long as you do require('mock-fs') before using any fs method, the prepatch will work for nodejs v10+ readFile.
This new patch only works for ReadFileContext (used by fs.readFile), because its require is delayed (`if (!ReadFileContext) ReadFileContext = require('internal/fs/read_file_context')`)
Previous _writev patch is still required to bypass issue on WriteStream.

fixes #264, properly fixes #254
@3cp 3cp changed the title WIP fix: prepatch fs-binding to improve support nodejs v10+ readFile fix: prepatch fs-binding to improve support nodejs v10+ readFile Apr 1, 2019
@3cp
Copy link
Collaborator Author

3cp commented Apr 1, 2019

Hi @tschaub could you review this?

@tschaub tschaub merged commit 6d4ca5b into tschaub:master Apr 22, 2019
@tschaub
Copy link
Owner

tschaub commented Apr 22, 2019

Thanks again for the work on this @huochunpeng. Published in mock-fs@4.9.0.

@3cp 3cp deleted the node10 branch May 2, 2019 02:32
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

Successfully merging this pull request may close these issues.

Mixing real fs calls with mocks hangs process. Only works the first time
2 participants