Skip to content

fix(server): Keep the idle limit on tunnels and proxied connections - #58

Merged
dcramer merged 2 commits into
mainfrom
fix/tunnel-idle
Nov 5, 2026
Merged

dcramer merged 2 commits into
mainfrom
fix/tunnel-idle

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Two kinds of connection lost their 10-minute idle limit.

  • Plain-HTTP tunnel: after the first request, Node sets the socket timeout to keepAliveTimeout + 1 s (6 s), then to server.timeout || 0 at the next request. So a hung second request had no limit. The fix sets tunnelServer.timeout.
  • Main server (absolute-form proxy requests and control calls): it never had a socket timeout. requestTimeout stops once Node has read the request, so a hung upstream or a client that stops reading held the connection with no limit. The fix sets server.timeout to the same 10 minutes, because model calls can be slow before the first byte.

TUNNEL_IDLE_MS is renamed to IDLE_MS. The README has an idle-limit bullet, and the keep-alive note now says 6 s.

Tests: an it.each reads the timeout the service sets during a hung second request, for a tunnel and for an absolute-form connection. Both fail on main with expected +0 to be 600000. pnpm check passes (116 tests).

An independent review confirmed the root cause in Node 24's _http_server.js and reproduced the main-server gap.

The docs cleanup PR is stacked on this one, because both edit the same README lines.

via @dcramer.

--

View Session [Sentry]

sentry-junior Bot and others added 2 commits November 5, 2026 18:30
A `CONNECT` tunnel gets a 10-minute idle limit on its raw socket. In a
tunnel without TLS, the tunnel server of Node uses that socket. After a
response, Node sets the limit to its keep-alive time (5 s and 1 s more),
and at the next request it sets it to the `timeout` of the server, which
was 0. So the limit went 600000 -> 6000 -> 0, and a second request that
hung, such as one whose body or upstream never came, had no idle limit.

Set `timeout` of the tunnel server to the idle limit, so Node sets the
socket back to 10 minutes at each new request. A TLS tunnel keeps the
limit of its raw socket as before, and its TLS socket gets the same
limit.

The new test reads the limit that the service sets on its end of a plain
tunnel at the second request. It gets 0 on main and 600000 now.

Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
Node's requestTimeout stops when a request is read, and the main server
had no timeout. A request that waited on a hung upstream, or a client
that did not read its response, held the connection with no limit. Set
the same 10-minute idle limit as the tunnel server.

Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
@sentry-junior
sentry-junior Bot added this pull request to stack #60 November 5, 2026 19:30
@dcramer
dcramer marked this pull request as ready for review November 5, 2026 19:33
@dcramer
dcramer merged commit f36d3a5 into main Nov 5, 2026
18 of 19 checks passed
@dcramer
dcramer deleted the fix/tunnel-idle branch November 5, 2026 19:36
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.

1 participant