by kiwicopple · 3y ago · 0 comments
This is a webserver for Deno. It is MIT licensed, written in Rust, and based on the latest Deno Runtime (1.32+). It can serve TypeScript, JavaScript, and WASM functions.
This one is important for local development and self-hosting. For local development, it ensures there is parity between development and production. For self-hosting, it means you can deploy and manage your Deno Functions on your own hardware. We have provided a Demo repository for deploying to Fly.io [1]. The runtime is not production-ready, but it is in a usable state. Note that we still use Deno Deploy at Supabase, and strongly recommend it for your own Deno functions.
In the medium-term, this will reduce our tech-stack by 1 service. We'll remove Kong (a reverse proxy) and replace it with the Deno runtime. I'm excited about some other possibilities that this provides for self-hosting - one that we talked about was the ability to bundle a SQLite file with your functions, for a fully-contained and globally deployed webserver.
The team will be around if you have any questions
[1] Deploy on Fly: https://github.com/supabase/self-hosted-edge-functions-demo
I've been dabbling with deno for a couple years now, one of the most powerful features I'm excited about is BroadcastChannel[1] support, which works with --unstable in Deno Deploy.
One of the challenges I've run into is debugging timeouts in deno deploy, so I'm curious--
1. is BroadcastChannel supported in supabase self-hosted edge functions? 2. is there more tooling available to supabase edge functions to debug than currently in deno deploy?
[1]: https://deno.com/deploy/docs/runtime-broadcast-channel
--- if curious of specifics, this is my work in progress proof of concept, exploring using pathnames for channels, to get anyone on the same url path connected across regions through sockets and broadcast channel: https://github.com/tylerchilds/kickstart/blob/869506c9dae1e1...
Thanks! Good Questions
1. We haven't enabled BroadcastChannel in the Edge Runtime. Mainly because we haven't found good use cases for it within Edge Functions (it does make sense as a way to subscribe within a browser client, but not sure how it fits with async/short-lived nature of Edge Functions). Curious about how you plan to use BroadcastChannel in Edge Functions?
2. As I've mentioned in the blog post Edge Runtime allows you to tweak the duration and memory available for an Edge Function (check the examples/main/index.ts in the repo too). Personally, I use this option to debug timeouts and memory issues on Edge Functions. We also plan to introduce better ways to profile your Edge Functions in the future.
I don't think my use-case is necessarily a good fit for edge functions. I am trying to achieve what Supabase realtime/multiplayer accomplishes, but generically. I participate informally with the https://braid.org IETF working group, which to over-simplify is CRDTs over HTTP with subscriptions.
I'm interested in web standards and that's what's drawn me to deno, so I'm super excited the more and more I see it being adopted. BroadcastChannel piques my interest because it is perfectly in that gray area of standardization-- it makes total sense on the client and we're on the cusp of discovering what that could look like for servers.
In deno deploy, all the instances of my service are able to be linked together by BroadcastChannel, which I'm viewing as a p2p-style architecture. Ultimately, I'm curious about how this works under the hood and if it would be possible to interoperate a BroadcastChannel between Deno Deploy, Supabase, and say a Raspberry Pi in my house.
I've gone on a bit of a tangent, but I think maybe I should get involved with the WinterCG, since now that I'm putting my thoughts to words-- seems like it fits their charter.
Our Lambdas are currently written in Typescript and built with esbuild. We zip them and push to AWS.
It’s also the case that there’s just so much historical baggage within Node, mainly with regard to CJS. Developing against Deno at least presents the opportunity for us to move past that and improve DX.
Kinda wish Amazon would have an alternative runtime that was more like this. They kinda do with lambda@edge, but that’s only for CloudFront stuff, mostly.
At a certain level of scale, the cost of spinning of an ALB Fargate task (which could run these servers relatively easily) ends up being relatively negligible. Although that’s certainly not true for every org.
Is any work being done to fix this? Or is this out of scope currently?
[0] https://github.com/denoland/deno/issues/7010#issuecomment-14...
I see there's a 1.0 Swift library that's available, would love if someone can chime in with their experience using that in an iOS app.
There were a few kinks initially, like URL polyfil being missing from RN and the need for AsyncStorage alongside supabase.js but they've all been rectified by the team or made more clear using their Expo instructions in the docs — Although maybe it'd be clearer for people that the expo guide is for RN? People who haven't started using RN might not know the connection?
It's such a pleasant stack, we're experimenting currently with edge functions in place of an API in certain places, so far it's just to use Cloudflare Turnstile to insert contact form records into a database, but it's super trivial.
Excited for the future of edge functions!
We also support swift: https://supabase.com/docs/reference/swift/introduction
One more thing - we will have some more announcements for mobile (specifically auth) tomorrow.
2. We encourage all of our developers to participate in the discussions, I just am usually just faster to respond.
3. Personally: I love HN and the community. I read it every day and learn a lot from it. I'm a developer like most other readers
The other motivation for doing this is that it makes our API Gateway programmable with user defined functions. For example, you could implement custom transformations for storage or augment the Authorization header with custom claims before calling Postgrest.