Skip to content

Userland access to internalBinding (at one's own risk) #27061

@bengl

Description

@bengl

At Intrinsic, we make use of process.binding('natives') in order to re-evaluate Node.js core modules inside our isolation environment. In order for these modules to work, we need to have the binding layer accessible. This is similar to how the natives module works.

The introduction of internalBinding was of no issue on its own, since we could just use process.binding to replicate its behaviour. However, there are now modules such as string_decoder that now having binding parts that are inacessible to userland. We can't simply require that users run with --expose-internals as our customers aren't always in control of CLI arguments. Also, our product is delivered as a Node.js module, rather than a separate binary, and we'd like to keep it that way.

Note: The natives module is subject to the same issue. Here is a quick example using RunKit.

We do have some workarounds involving re-implementing the exposed APIs, but we find this to be prone to errors and subject to extra maintenance for new versions of Node.js.

What we'd like to do is introduce a way of accessing internalBinding-provided code from userland. I know this seems counterintuitive, given the purpose of internalBinding, so it would make the most sense for it to be provided in C++ only, requiring some native code to actually get access to it. The difficulty in accessing it is an acknowledgement that we're not expecting the same level of support that the normal user-facing API has. (We would expect basically no support for the actual internal bindings, but we wouldn't expect this access to disappear.) We're certainly open to other suggestions, but we'd like a solution that's maintainable and sustainable.

What do folks think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions