How supabase/edge-runtime works
This project – Supabase Edge Runtime – is a high-performance, self‐hosted Deno web server built to run JavaScript, TypeScript, and WASM services at the edge. It is organized into multiple Rust crates (each handling core functionality such as the base runtime, filesystem, HTTP utilities, Deno interfacing, etc.), a CLI tool, examples, and even extensions (“ext” directory) that provide additional integrations. The README clearly defines two key “runtimes”: the Main runtime (which handles entry, proxying, and security tasks such as authentication and environment variable management) and the User runtime (which executes user functions under controlled resource limits like memory and timeouts).
Main Components
• HTTP Request Interface – an entrypoint that accepts incoming HTTP requests.
• Main Runtime – the gateway that authenticates, validates, and then proxies requests.
• User Runtime – the sandboxed execution environment where user functions run with restrictions (e.g., limited memory, timeouts).
• Supporting Modules/Crates – core libraries including the “base” crate, “fs” (file system), “http_utils”, “deno_facade”, “cpu_timer”, and others that provide features such as module loading (eszip_trait), caching, and runtime utilities.
• CLI Tool – provides command‐line functionality to launch the server and manage configurations.
• Extensions (“ext” directory) – enhance integration with external APIs and add support for Node-like polyfills.
Relationships and Interactions
• Examples of how supporting crates (like “fs” for file caching and “cpu_timer” for monitoring execution time) are used to underpin the low-level functionalities.