Skip to content

Avoid using process.binding() #1059

@jcbhmr

Description

@jcbhmr

process.binding() is used in the preview2 and preview3 shims https://github.com/search?q=repo%3Abytecodealliance%2Fjco+process.binding&type=code

There's a comment #154 (comment) about how "We need to be able to support other JS runtimes, so avoid as much as we can depending on Node.js's libuv bindings." and it was deemed "After giving this some thought, and in order to meet our deadline, I think we should keep the current wasi-sockets implementation, based on tcp_wrap as is for now."

I don't see process.binding() in the official Node.js docs https://nodejs.org/api/process.html (Ctrl+F for "binding" finds 1 irrelevant result). From my understanding it's an internal method to get access to the native C++ <=> JS bridge interface that Node.js uses internally.

Luckily it's only in one spot!

const { TCP, constants: TCPConstants } = process.binding('tcp_wrap');

I don't know how easy it would be to not use process.binding() but I think it would be worth it. This is causing issues with cross-runtime compatibility oven-sh/bun#18635

This is a friendly feature request issue for broader runtime support. ❤️

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions