Skip to content

fix: add fetch timeout and TCP keepalive to HTTP client#694

Merged
nyannyacha merged 1 commit into
mainfrom
ny/fetch-timeout-and-keepalive
Apr 21, 2026
Merged

fix: add fetch timeout and TCP keepalive to HTTP client#694
nyannyacha merged 1 commit into
mainfrom
ny/fetch-timeout-and-keepalive

Conversation

@nyannyacha
Copy link
Copy Markdown
Contributor

@nyannyacha nyannyacha commented Apr 21, 2026

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

The HTTP client does not have a timeout for fetch requests or TCP keepalive settings.

What is the new behavior?

  • TCP keepalive is now enabled on HTTP client sockets (SO_KEEPALIVE). The OS will send keepalive probes after an idle period, detecting and closing dead connections before they cause indefinite hangs. Default idle time is 30s, configurable via DENO_TCP_KEEPALIVE_SECS.
  • A fetch timeout is now applied to both response header wait and body download in the file fetcher. Configurable via DENO_FETCH_TIMEOUT_SECS (disabled by default).

Description

Without TCP keepalive, if a load balancer (e.g. AWS ALB with a 60s idle timeout) silently drops a pooled connection, the client has no way to detect the dead socket and send().await blocks indefinitely. This was observed causing 1h+ hangs in the bundle subcommand and silent failures when invoking functions from within Edge Functions (ref #678).

Context: https://supabase.slack.com/archives/C02KMRX22NR/p1776767117730769?thread_ts=1776681851.847949&cid=C02KMRX22NR

@nyannyacha nyannyacha merged commit b4cf8eb into main Apr 21, 2026
4 checks passed
@nyannyacha nyannyacha deleted the ny/fetch-timeout-and-keepalive branch April 21, 2026 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants