Merge contrib: cap concurrent requests, from an outside contributor #75

Merged
chrnx merged 2 commits from contrib into develop 2026-09-01 13:29:42 +00:00
Owner

Brings origin/contrib down to develop: limits.maxConcurrentRequests, opt-in, applied per server and per Fetch adapter instance. Over the budget, a request gets 503 with Retry-After: 1 instead of queueing behind the ones already running.

Two commits from @hgshreyas, both DCO signed off:

  • ff94e55 feat: cap concurrent requests across runtimes
  • 82e1678 fix: warn when connection limit drops a socket — Node's drop event was silent until now, so hitting maxConnections looked like a network fault from the outside. Rate-limited to one warning a minute.

The gate bounds concurrently executing handlers, not open connections: the slot is released when routing and the handler finish, so a long-lived stream or a WebSocket upgrade does not hold one for its lifetime. On Node a client disconnect releases the slot early. A handler that never returns keeps its slot, which is the honest behaviour for a budget of this shape.

contrib is a strict descendant of develop, so this merges without a conflict.

Verified on ff94e55

lint               0 errors (48 pre-existing warnings)
complexity:check   every function <= 25
typecheck          clean
format:check       clean
build              clean
npm test           453 passed / 67 files
test:deno          12 passed
test:bun           7 passed
test:edge          PASS

Known follow-ups, deliberately let through

Both were filed against this branch rather than held against it, so it can land:

  • #73 — the shed request emits request:end with no request:start, the first pair in the tree to break. The decision owed is whether the pairing is a guarantee, not whether this PR is wrong.
  • #74 — the close listener and the acquire bookkeeping run on every request, including in apps that never set the limit.
Brings `origin/contrib` down to `develop`: `limits.maxConcurrentRequests`, opt-in, applied per server and per Fetch adapter instance. Over the budget, a request gets `503` with `Retry-After: 1` instead of queueing behind the ones already running. Two commits from @hgshreyas, both DCO signed off: - `ff94e55` feat: cap concurrent requests across runtimes - `82e1678` fix: warn when connection limit drops a socket — Node's `drop` event was silent until now, so hitting `maxConnections` looked like a network fault from the outside. Rate-limited to one warning a minute. The gate bounds *concurrently executing handlers*, not open connections: the slot is released when routing and the handler finish, so a long-lived stream or a WebSocket upgrade does not hold one for its lifetime. On Node a client disconnect releases the slot early. A handler that never returns keeps its slot, which is the honest behaviour for a budget of this shape. `contrib` is a strict descendant of `develop`, so this merges without a conflict. ## Verified on ff94e55 lint 0 errors (48 pre-existing warnings) complexity:check every function <= 25 typecheck clean format:check clean build clean npm test 453 passed / 67 files test:deno 12 passed test:bun 7 passed test:edge PASS ## Known follow-ups, deliberately let through Both were filed against this branch rather than held against it, so it can land: - #73 — the shed request emits `request:end` with no `request:start`, the first pair in the tree to break. The decision owed is whether the pairing is a guarantee, not whether this PR is wrong. - #74 — the `close` listener and the acquire bookkeeping run on every request, including in apps that never set the limit.
chrnx added 2 commits 2026-09-01 13:28:19 +00:00
Signed-off-by: hgshreyas <hgshreyas.cs24@bmsce.ac.in>
feat: cap concurrent requests across runtimes
CI / dco (push) Has been skipped
CI / build (push) Successful in 28s
CI / runtimes (deno) (push) Successful in 19s
CI / runtimes (bun) (push) Successful in 59s
CI / runtimes (edge) (push) Successful in 11s
CI / dco (pull_request) Successful in 6s
CI / runtimes (bun) (pull_request) Successful in 16s
CI / runtimes (edge) (pull_request) Successful in 12s
CI / runtimes (deno) (pull_request) Successful in 21s
CI / build (pull_request) Successful in 29s
ff94e55496
Signed-off-by: hgshreyas <hgshreyas.cs24@bmsce.ac.in>
chrnx merged commit d93037e2a0 into develop 2026-09-01 13:29:42 +00:00
Sign in to join this conversation.