Skip to content

internalModuleStat & internalModuleReadJSON prevent resolution override #33423

Open
@arcanis

Description

@arcanis

What steps will reproduce the bug?

Imagine that the fs module is overriden to add support for a virtual filesystem. Make a require call towards a virtual file.

What is the expected behavior?

The resolution should succeed, since the fs methods know how to access the file.

What do you see instead?

Cannot find module 'virtual'.

Additional information

This occurs because Node cheats and doesn't actually use all of the fs methods. In most cases it does (for example fs.realpath, fs.readFile, fs.readdir), but not for all. Two methods in particular goes into unique native bindings that cannot be overriden:

Since those functions aren't exposed (not only do they come from internalBinding, they're also destructured so we never have a chance to change their references), we cannot even add the virtual layer to them at all.

Would it be possible to use the fs primitives or, at least, to expose internalModuleStat & friends in a way we can wrap them?

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to the fs subsystem / file system.moduleIssues and PRs related to the module subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions