stack: the HTTP gateway closes idle keep-alive connections after 5 s, so a client whose event loop is blocked gets ECONNRESET (`fetch failed`) on its next request
I maintainer di solito rispondono entro 1 giorno
@7ttp ci sta già lavorando.
Dal 3/10/2026.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 84/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- node.js, typescript
Direzione di ricerca
Inizia da packages/stack/src/HttpProxy.ts, in particolare da createServer(...) e dal commento esistente sul timeout dell’Agent upstream. Esegui la riproduzione keepalive-race.mjs fornita sullo stack nativo e verifica che un blocco dell’event loop del client più lungo di cinque secondi non reimposti più la richiesta successiva. Il timeout keep-alive lato client deve essere superiore a cinque secondi, mantenendo headersTimeout al di sopra di esso.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Affected area
Local development
Supabase CLI version
2.119.0
Operating system
macOS 26.7 on Apple silicon, native runtime. First seen on a GitHub Actions ubuntu-latest runner (x64), native runtime.
Installation method
pnpm
Command
supabase start --runtime native # [experimental] stack = true in config.toml
Actual output
The stack's HTTP gateway (the listener behind API_URL) advertises a five-second idle timeout on every response and closes an idle client connection after it:
$ curl -sI "$API_URL/rest/v1/" -H "apikey: $PUBLISHABLE_KEY"
HTTP/1.1 200 OK
server: postgrest/16.4
Connection: keep-alive
Keep-Alive: timeout=5
A Node client whose event loop is free is not affected: fetch's connection pool drops the idle socket in time, and sequential requests seconds apart all succeed. A client whose event loop is blocked for longer than five seconds between two requests on the same connection (a synchronous child process, a long GC pause) cannot do that; the gateway closes the socket first, the client writes its next request to it, and the request fails:
warm: 200
after 4 s with the event loop blocked: 200
warm: 200
after 6 s with the event loop blocked: fetch failed (ECONNRESET)
warm: 200
after 6 s with the event loop free: 200
Through supabase-js this surfaces as TypeError: fetch failed, with nothing about the cause. It first hit us in CI: an end-to-end seed called the Data API, ran two builds with execFileSync, and called the Data API again. It passed on a laptop, where the two builds took less than five seconds, and failed on an ubuntu-latest runner. The same seed had run unchanged against the Docker stack (Kong) for weeks.
Expected behavior
The gateway keeps an idle client connection long enough that a stall of a few seconds in a client does not become a connection reset, as the Docker stack's gateway did: an explicit keepAliveTimeout well above the runtime's five-second default, with headersTimeout kept above it.
Steps to reproduce
supabase start --runtime nativein a project with[experimental] stack = true.- Put
API_URLandPUBLISHABLE_KEYfromsupabase status --envin the environment. - Save the script below as
keepalive-race.mjsand runnode keepalive-race.mjs(Node 24.21.0 here). The request after a six-second block fails withECONNRESET; the same gap with the loop free succeeds.
import { execFileSync } from "node:child_process";
const url = `${process.env.API_URL}/rest/v1/`;
const headers = { apikey: process.env.PUBLISHABLE_KEY };
async function get(label) {
try {
const response = await fetch(url, { headers });
await response.text();
console.log(`${label}: ${response.status}`);
} catch (error) {
console.log(`${label}: ${error.message} (${error.cause?.code})`);
}
}
for (const seconds of [4, 6]) {
await get("warm");
execFileSync("sleep", [String(seconds)]); // blocks the event loop, as any synchronous work does
await get(`after ${seconds} s with the event loop blocked`);
}
await get("warm");
await new Promise((resolve) => setTimeout(resolve, 6000)); // the same gap with the loop free
await get("after 6 s with the event loop free");
Additional context
packages/stack/src/HttpProxy.ts(v2.119.0, unchanged ondevelop) creates the client-facing server withcreateServer(...)and sets nokeepAliveTimeout, so the runtime's default of five seconds applies. The same file already guards the gateway's own upstream connections against this race:new Agent({ keepAlive: true, timeout: 4_000 }), with the comment "Idle sockets close before Node upstreams' default 5 s keep-alive timeout can race a reuse." The client-facing side has no equivalent.- #6922 covered the upstream half of the gateway's connection handling; this is the client-facing half.
- We fixed our side by not blocking the event loop between requests, which is the right shape regardless, so this is a report rather than a blocker.
- Lingua principale
- TypeScript
- Stelle
- 2.4k
- Fork
- 531
- Merge medio
- 1g 3h
- PR unite (30g)
- 332
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di supabase/cli
-
📘 Docs supabase/cli
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Migration error caret is missing or misplaced when the statement contains multibyte charactersAperta🐛 Bug supabase/cli
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
stack: functions serve fails without a TTY because the default output format is one it rejectsAperta🐛 Bug supabase/cli
Difficoltà 3/5 Mezza giornata Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
stack: functions serve fails with "Dependent … blocks restart of …" after a plain supabase startAperta🐛 Bug supabase/cli
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
I maintainer di solito rispondono entro 1 giorno
-
🐛 Bug supabase/cli
Difficoltà 4/5 3-5 giorni Idoneità per principianti 32/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di supabase/cli
Issue simili
-
dx hacktoberfest help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
cloudflare/agents#2498 ·
I maintainer di solito rispondono entro 1 giorno
-
Missing repro Platform: Android
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
software-mansion/react-native-reanimated#10816 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
e2e-failure ready-to-code
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
redhat-developer/rhdh-plugin-export-overlays#4129 ·
I maintainer di solito rispondono entro 1 giorno