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

Support for fs.opendir() #319

Open
voxpelli opened this issue Mar 11, 2021 · 4 comments
Open

Support for fs.opendir() #319

voxpelli opened this issue Mar 11, 2021 · 4 comments

Comments

@voxpelli
Copy link

Noticed that mock-fs currently doesn't support fs.opendir (added in Node.js 12.12.0), which made one of my modules, list-installed, not recognize the mocked data which I tried to make it act on in another of my modules.

Since I couldn't see a mention of this I thought I should open an issue to keep track of it.

@3cp 3cp self-assigned this Mar 12, 2021
@3cp
Copy link
Collaborator

3cp commented Mar 13, 2021

Running into big trouble.
Mock-fs works through replacing Nodejs internal binding for fs.

But in Nodejs v12.12.0+, it introduced another internal binding fs_dir.

https://github.com/nodejs/node/blob/7296bcb3cb937ee6b3d607f8cfb84db21ebb069d/lib/internal/fs/dir.js#L15-L16

The problem is, the new fs_dir binding is not exposed to user code.

https://github.com/nodejs/node/blob/7296bcb3cb937ee6b3d607f8cfb84db21ebb069d/lib/internal/bootstrap/loaders.js#L73-L107

We could not grab the existing fs_dir binding through process.binding('fs_dir'). It means we could not replace/restore it.
@tschaub any idea how to work around this?

@3cp
Copy link
Collaborator

3cp commented Mar 14, 2021

From the above linked Nodejs issue, it's unlikely that Nodejs will open up fs_dir access.

@voxpelli
Copy link
Author

Thanks for looking into it! I guess this becomes a wider issue then, maybe ultimately requiring another approach to patching. Feel free to close this for now if you think that would be out of scope for this.

@m4s0
Copy link

m4s0 commented May 11, 2022

Thanks for looking into it! I guess this becomes a wider issue then, maybe ultimately requiring another approach to patching. Feel free to close this for now if you think that would be out of scope for this.

@voxpelli how did you solve it?

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