wintercg / proposal-sockets-api

Proposal for an API for establishing TCP connections in Non-Browser JavaScript runtime environments
https://sockets-api.proposal.wintercg.org/
Other
46 stars 2 forks source link

Implications of global `connect` method being apart of spec #1

Closed Ethan-Arrowood closed 10 months ago

Ethan-Arrowood commented 10 months ago

The spec dictates that the connect method should be globally available. I think this may inhibit adoption; especially in Node.js. It may be worth reconsidering, or at least providing some alternative. Or at the minimum, maybe we bring this up to Node.js and see what their initial thoughts are (happy to start this conversation). In general, globals concern me as we work to become interoperable between Node/Deno/Bun/Workerd/etc.

TooTallNate commented 10 months ago

IMO it should be a Socket global and Socket.connect() returns an instance of Socket.

dom96 commented 10 months ago

Ahh, I seem to have missed that in the spec, I will fix it.

The connect method isn't global anymore, in Cloudflare's case it is part of the cloudflare:socket module. I'll have the spec describe it as being part of the sockets module, but we can bikeshed on the name if this clashes with anything or there is a better name for it.