You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need to investigate how hard is it to build a realistic node:net#Socket polyfill using what we currently have in workerd's cloudflare:socket and nodejs_compat layer.
This came out of a discusstion about brianc/node-postgres#3170 with @petebacondarwin this morning where we are trying to improve our pg specific node:net#Socket polyfill. This made me wonder if a better path wouldn't be to beef up our node:net#Socket polyfill so that things just work.
Note: workerd has native implementation of node:stream#Duplex but since this unenv polyfill exports it via a relative import, the unenv polyfill will end up ignoring our implementation. This is something that should be fixed in unenv as part of the hybrid polyfill effort: unjs/unenv#181
The text was updated successfully, but these errors were encountered:
We ought to be able to get very close. There will likely be some edge cases or options that we're not able to support, but for the most part it should be doable
This would be great from the point of view of our idea of shimming Python socket with our socket. If we make the Python socket library work on top of node sockets then we can upstream it, potentially all the way into Emscripten.
We need to investigate how hard is it to build a realistic node:net#Socket polyfill using what we currently have in workerd's cloudflare:socket and nodejs_compat layer.
This came out of a discusstion about brianc/node-postgres#3170 with @petebacondarwin this morning where we are trying to improve our pg specific node:net#Socket polyfill. This made me wonder if a better path wouldn't be to beef up our node:net#Socket polyfill so that things just work.
Looking at https://github.com/brianc/node-postgres/blob/master/packages/pg-cloudflare/src/index.ts it seems that we are essentially creating a bespoke polyfill for node Socket there. So why not upstream this to unenv (or eventually workerd)?
The unenv polyfill doesn't seem terribly complex: https://github.com/unjs/unenv/blob/main/src/runtime/node/net/socket.ts because it simply extends from
node:stream#Duplex
.Note: workerd has native implementation of
node:stream#Duplex
but since this unenv polyfill exports it via a relative import, the unenv polyfill will end up ignoring our implementation. This is something that should be fixed in unenv as part of the hybrid polyfill effort: unjs/unenv#181The text was updated successfully, but these errors were encountered: