clone

a daily shikaku puzzle for phones: one seeded puzzle per date, solved by dragging rectangles

main
rect.run / .github / skills / deno-deploy / references / RUNTIME.md
RUNTIME.md 2.4K rendered
1# Deno Deploy Runtime23## Overview45Deno Deploy uses the standard Deno runtime. You can use JSR and NPM packages, filesystem operations, network requests, subprocesses, and FFI/native addons.67## Current Environment89- **Runtime:** Deno 2.5.010- **Platform:** Linux (x64 or ARM64)11- **Permissions:** All permissions enabled automatically (`--allow-all`)1213**Note:** Custom Deno flags cannot be passed to the runtime.1415## Serverless Lifecycle1617Understanding how your app starts and stops is important for building reliable applications.1819### Startup2021Your application starts when a request arrives. If your app crashes before the HTTP server starts, requests return a 502 error.2223**Tip:** Keep startup fast by:24- Reducing dependencies25- Using dynamic imports for rarely-used code26- Avoiding network requests during startup2728### Idle Shutdown2930After 5-10 minutes without requests:311. The system sends a `SIGINT` signal322. Your app has 5 seconds to shut down gracefully333. If still running, `SIGKILL` terminates it3435```typescript36// Handle graceful shutdown37Deno.addSignalListener("SIGINT", () => {38 console.log("Shutting down...");39 // Clean up resources, close connections40 Deno.exit(0);41});42```4344### Eviction4546Even during active traffic, instances may be terminated due to:47- Infrastructure updates48- Resource constraints4950The system redirects traffic first, then signals shutdown. **Long-running connections should expect reconnections.**5152## Cold Start Performance5354Cold starts typically complete:55- **~100ms** for simple "hello world" apps56- **A few hundred ms** for larger applications5758Deno Deploy optimizes cold starts using:59- Pre-provisioned microVMs60- Early TCP connection setup61- File system warmup6263### Minimizing Cold Start Time6465```typescript66// BAD: Top-level network request delays startup67const config = await fetch("https://api.example.com/config").then(r => r.json());6869// GOOD: Lazy load on first request70let config: Config | null = null;71async function getConfig() {72 if (!config) {73 config = await fetch("https://api.example.com/config").then(r => r.json());74 }75 return config;76}77```7879## Limitations8081| Feature | Status |82|---------|--------|83| Custom Deno flags | Not supported |84| Persistent filesystem | Use Deno KV instead |85| Long-running background tasks | May be interrupted |86| System tools | Available but may change |8788## Documentation8990- Runtime reference: https://docs.deno.com/deploy/reference/runtime/