stack: every Edge Function request starts a new worker, so the same function never reuses one and each call pays a cold start
Maintainer antworten meist innerhalb von 1 Tag
@7ttp arbeitet bereits daran.
Seit 27.10.2026.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 58/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- deno, typescript
Rechercherichtung
Start in packages/stack/src/functions/serve.main.ts near line 466, where the issue reports forceCreate: true, and compare it with apps/cli/src/shared/functions/serve.main.ts near line 516. Reproduce with the supplied hello function and repeated curl calls on the experimental stack. Done when subsequent requests reuse the worker and its request count increases, matching the legacy stack.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Affected area
Edge Functions
Supabase CLI version
2.121.0
Operating system
macOS 27.0.1 (Apple silicon)
Installation method
pnpm
Command
SUPABASE_EXPERIMENTAL_STACK=1 supabase start --runtime native
for i in 1 2 3 4 5; do curl -s -w ' %{time_total}s\n' http://127.0.0.1:54321/functions/v1/hello; done
Actual output
{"requests":1,"workerStartedAt":"2026-10-22T04:47:49.507Z","xForwardedFor":null,"xRealIp":null} 1.111719s
{"requests":1,"workerStartedAt":"2026-10-22T04:47:49.553Z","xForwardedFor":null,"xRealIp":null} 0.023354s
{"requests":1,"workerStartedAt":"2026-10-22T04:47:49.586Z","xForwardedFor":null,"xRealIp":null} 0.018719s
{"requests":1,"workerStartedAt":"2026-10-22T04:47:49.613Z","xForwardedFor":null,"xRealIp":null} 0.017223s
{"requests":1,"workerStartedAt":"2026-10-22T04:47:49.645Z","xForwardedFor":null,"xRealIp":null} 0.021565s
# same project on the legacy stack (SUPABASE_EXPERIMENTAL_STACK=0 supabase start)
{"requests":1,"workerStartedAt":"2026-10-22T04:48:40.137Z","xForwardedFor":"192.168.171.1","xRealIp":"192.168.171.1"} 0.056585s
{"requests":2,"workerStartedAt":"2026-10-22T04:48:40.137Z","xForwardedFor":"192.168.171.1","xRealIp":"192.168.171.1"} 0.004061s
{"requests":3,"workerStartedAt":"2026-10-22T04:48:40.137Z","xForwardedFor":"192.168.171.1","xRealIp":"192.168.171.1"} 0.003451s
{"requests":4,"workerStartedAt":"2026-10-22T04:48:40.137Z","xForwardedFor":"192.168.171.1","xRealIp":"192.168.171.1"} 0.003629s
{"requests":5,"workerStartedAt":"2026-10-22T04:48:40.137Z","xForwardedFor":"192.168.171.1","xRealIp":"192.168.171.1"} 0.003386s
On the experimental stack requests stays at 1 and workerStartedAt changes on every call, so each request gets a brand new worker. The legacy stack keeps one worker and counts up.
Expected behavior
Requests to the same function reuse its running worker, as they do on the legacy stack. Only the first call should pay for booting the worker.
Steps to reproduce
mkdir repro && cd repro && supabase init- Create
supabase/functions/hello/index.ts:let requests = 0; const workerStartedAt = new Date().toISOString(); Deno.serve((req) => Response.json({ requests: ++requests, workerStartedAt, xForwardedFor: req.headers.get("x-forwarded-for"), xRealIp: req.headers.get("x-real-ip"), }) ); - Add to
supabase/config.toml:[functions.hello] verify_jwt = false SUPABASE_EXPERIMENTAL_STACK=1 supabase start --runtime native, then call the function a few times as above.requestsis always 1.- Stop it, start the legacy stack with
SUPABASE_EXPERIMENTAL_STACK=0 supabase start(I passed-xfor everything except the database, Kong and the edge runtime) and make the same calls.requestscounts up.
(The two header fields are for #7275 and don't matter here.)
Crash report ID
No response
Docker and service versions
Docker: Client 29.8.2, Server 29.8.2 (linux/arm64)
supabase/postgres 17.11.0.004
supabase/gotrue v2.197.0
postgrest/postgrest v16.4
supabase/realtime v2.143.4
supabase/storage-api v1.82.1
supabase/edge-runtime v1.77.4
supabase/studio 2026.10.12-sha-3699278
supabase/postgres-meta v0.100.0
supabase/logflare 1.53.0
supabase/supavisor 2.9.13
Additional context
In the v2.121.0 tag (97531eb590ccd2c5cf215287ae03e877180810b4), the experimental stack's functions main passes forceCreate: true to EdgeRuntime.userWorkers.create (packages/stack/src/functions/serve.main.ts:466). The legacy main sets const forceCreate = false (apps/cli/src/shared/functions/serve.main.ts:516). develop and next still have forceCreate: true on the same line.
On a hello-world function the cost is small, about 20 ms per call instead of 4 ms. On our real project the functions import a lot more, and every call to the same function took 0.55 to 0.65 s on the native runtime, against 4 ms warm on the legacy stack. That makes the native runtime too slow for our local development and E2E runs, which is the main thing keeping us on Docker.
If forceCreate: true is there so code edits show up on the next request, reusing the worker until a file under the function changes would keep that without a cold start on every call.
I investigated this with help from an AI coding assistant (Claude Code), which also drafted this text. The results above come from real runs.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 2.4k
- Forks
- 540
- Ø Merge
- 17 Std. 29 Min.
- Gemergte PRs (30 T.)
- 387
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus supabase/cli
-
db schema declarative sync: no way to fail (non-zero exit) when the generated migration is destructiveEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen✨ Feature supabase/cli
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
Maintainer antworten meist innerhalb von 1 Tag
-
`supabase start` waits about 10 seconds for Docker's first health check after services are readyOffen🐛 Bug supabase/cli
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 70/100
Maintainer antworten meist innerhalb von 1 Tag
-
🐛 Bug supabase/cli
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
Maintainer antworten meist innerhalb von 1 Tag
-
🐛 Bug supabase/cli
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
supabase/cli#7269 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Explicit local function bundling falls back to API bundling when Docker is unavailableEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen🐛 Bug open-for-contribution supabase/cli
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
supabase/cli#7214 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Northeastern-Electric-Racing/FinishLine#4660 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
excaliburjs/Excalibur#3895 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
infer_audio_type only recognises one MPEG Layer III frame header, so most MP3 files are rejectedEvtl. vergeben @Steve-20-ai hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Earn report crashes with "RangeError: Invalid time value" when a report row has an unparsable timestampEvtl. vergeben @Gurkaran18 hat das heute übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
joinmarket-webui/jam#1588 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
BeOS .json missingOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
mihaip/infinite-mac#475 ·