Re:Cloudflare Workers Introduces Connect() API to Create TCP...
by danwee on Monday May 29, 2023 @08:53AM
(#36113462)
I don't understand something: "Cloudflare workers" are, at the end of the day, computers, right? Probably virtual ones (either VMs or containers). So, why is the ability of creating TCP sockets a feature? Why their "cloudflare workers" had that handicap to begin with?
[ Parent
| on HN ]
Re:Cloudflare Workers Introduces Connect() API to Create TCP...
by paulgb on Monday May 29, 2023 @09:22AM
(#36113682)
They are neither VMs or containers, but V8 Isolates. They lacked an API for making outgoing raw TCP connections in the same way that JavaScript running in a browser can’t.
Re:Cloudflare Workers Introduces Connect() API to Create TCP...
by poxrud on Monday May 29, 2023 @11:32AM
(#36114918)
This used to be an option in Chrome when running in an extension. Sadly sockets were removed in manifest v3.
Re:Cloudflare Workers Introduces Connect() API to Create TCP...
by silentsea90 on Monday May 29, 2023 @12:39PM
(#36115506)
I was lost about the distinction. This talk really helped: https://www.infoq.com/presentations/cloudflare-v8/
Re:Cloudflare Workers Introduces Connect() API to Create TCP...
by zuprau on Monday May 29, 2023 @11:44AM
(#36115021)
I might be wrong, but they're more like a browser’s "service worker" than a Node app.[0] The fact that they have to manually add "compatibility" with Node modules like `utils`[1] seems to support this.
[0]: https://blog.cloudflare.com/node-js-support-cloudflare-worke...
[1]: https://blog.cloudflare.com/workers-node-js-asynclocalstorag...
Re:Cloudflare Workers Introduces Connect() API to Create TCP...
by crabmusket on Monday May 29, 2023 @08:43PM
(#36119891)
That's exactly right, and they even use the same API[1] for accepting and replying to HTTP requests . As well as supporting other service worker APIs like caches.
[1] https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent