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

Official fs overlay #172

Open
arcanis opened this issue Nov 14, 2023 · 3 comments
Open

Official fs overlay #172

arcanis opened this issue Nov 14, 2023 · 3 comments

Comments

@arcanis
Copy link
Contributor

arcanis commented Nov 14, 2023

With the addition of PRs like nodejs/node#48658 or nodejs/node#49593 virtual filesystem overlays are in an uncomfortable position where Node both doesn't respect anymore its own APIs (ie fs). We currently workaround that by patching some primitives from process.binding('fs'), but this is untenable, even at short term (nodejs/node#50687).

We often heard that "one of our goals is to allow mocking of modules, including of builtins; but only via loaders". That's fine to me, but given the recent acceleration of PRs aiming to shortcut fs it suggests now is the time to start discussing in details what such an overlay would look like that would satisfy everyone.

@targos
Copy link
Member

targos commented Nov 14, 2023

How should we start the discussion? Depending on what we are talking about, this might interest the @nodejs/fs team, and people working on the permissions model.

Maybe we should try define first where this overlay would be placed?

There are several layers, currently:

  • Native OS/system calls
  • libuv
  • C++ bindings
  • Internal JS functions
  • the public fs module

@arcanis
Copy link
Contributor Author

arcanis commented Nov 14, 2023

The current way of patching fs lives between "C++ bindings" and "Internal JS functions" layers, but on the JS side. This model worked quite well so far, proving very flexible in the context of JS packages.

As for permissions, I suspect we'd want any hooking API to still live within the limits of whatever permissions were given to the process. We don't want to accidentally open a bypass, and implementing this layer in JS-land would prevent that (my understanding being that permissions are implemented at a lower level?).

@joyeecheung
Copy link
Member

This sounds like a nodejs/node issue. We are also looking into it for single executable applications for example nodejs/single-executable#37

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