Skip to content

Expose internalBinding fs_dir #37746

Closed
Closed

Description

@3cp

Is your feature request related to a problem? Please describe.
tschaub/mock-fs#319
mock-fs works through replacing Nodejs internal binding for fs.
We encountered a technical blocker when implementing fs.opendir in mock-fs because the new internalBinding fs_dir is not exposed in process.binding('fs_dir').

Describe the solution you'd like
We would like to suggest to expose fs_dir binding here, so that we could replace it at runtime in mock-fs.

// internalBindingAllowlist contains the name of internalBinding modules
// that are allowed for access via process.binding()... This is used
// to provide a transition path for modules that are being moved over to
// internalBinding.
const internalBindingAllowlist = new SafeSet([
'async_wrap',
'buffer',
'cares_wrap',
'config',
'constants',
'contextify',
'crypto',
'fs',
'fs_event_wrap',
'http_parser',
'icu',
'inspector',
'js_stream',
'natives',
'os',
'pipe_wrap',
'process_wrap',
'signal_wrap',
'spawn_sync',
'stream_wrap',
'tcp_wrap',
'tls_wrap',
'tty_wrap',
'udp_wrap',
'url',
'util',
'uv',
'v8',
'zlib',
]);

Describe alternatives you've considered
N/A

Activity

  1. cjihrig commented on Mar 14, 2021

    @cjihrig
    Contributor

    Just FYI - there is an initiative already underway to deprecate userland access to process.binding(). It seems unlikely that a new binding would be intentionally exposed.

  2. 3cp commented on Mar 14, 2021

    @3cp
    Author

    Thx for the information.

  3. theoludwig commented on Sep 11, 2022

    @theoludwig
    Contributor

    Could this issue be reconsidered, please? @3cp @cjihrig

    If not, can someone tell me, how is tschaub/mock-fs#358 issue will be solved?
    More generally, what is the best way to mock node:fs today, supporting all the methods of fs?
    Is there a way that Node.js core can introduce a "mock" module, to easily mock such APIs for testing purposes, it might pair well with the new test_runner module.

  4. 3cp commented on Sep 11, 2022

    @3cp
    Author

    The way mock-fs works is too fragile.
    It's definitely best if nodejs is designed to facilitate testing (not just the fs module).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions