Repository navigation
Fix #1677: raise tunnel H2 flow-control windows and disable ws deflate - #1678
Merged
Merged
Conversation
Both browser WebSockets (VS Code management + extension-host) are proxied as two streams on one relay<->tower H2 session. Node's default 64 KB per-stream and connection windows let a large transfer on one stream starve tiny RPCs on the other (head-of-line blocking at the session window): the field trace saw a ~100 B management resolve take 39 s while a 1.3 MB upload drained. Raise the tower's inbound H2 windows and drop tunnel-level compression in packages/codev/src/agent-farm/lib/tunnel-client.ts: - settings.initialWindowSize = 1 MiB (per-stream receive window) - session.setLocalWindowSize(4 MiB) (connection receive window, larger than one stream so a big transfer can't consume the whole shared window) - perMessageDeflate: false on the tunnel WebSocket, so large DATA frames aren't CPU-inflated on the event loop, delaying small outbound frames Regression test reads the advertised windows back from the mock relay (H2 client) and asserts deflate is not negotiated; it fails at Node's 65535 B defaults and passes with the fix. The relay's own http2.connect must raise its windows for the outbound direction (separate deployment).
…e assertion - Add a SETTINGS settle guard to the per-stream window test (mirrors the connection-window test) to remove a theoretical ordering flake. - Reframe the perMessageDeflate comment as defence-in-depth (the relay is the ws server, whose default is already off), not an established third root cause. - Drop a redundant static-constant assertion in the connection-window test.
…olding at gate
…ive fix codev-cloud confirmed (2026-09-14) its /tunnel ws server runs ws defaults, so deflate is never negotiated and this client-side decline is a no-op today. Keep it as a documented guard against a future server-side enable; state that verified fact in the comment instead of the earlier speculative framing.
…d re-test choreography noted; holding at gate
…erge word, not merging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A tiny RPC on the VS Code management WebSocket (explorer
resolve, ~100 B request / ~3 KB reply) took 39 s through the cloud relay while a 1.3 MB upload drained on the extension-host WebSocket. Both browser sockets are proxied as two streams on a single relay↔tower HTTP/2 session, and the tower ran that session with Node's default 64 KB flow-control windows, so a large transfer on one stream starved small RPCs on the other. This raises the tower's inbound H2 windows and drops tunnel-level compression.Refs #1677 (partial fix: tower-side inbound H2 windows only; the relay's outbound half and the issue's end-to-end field re-test remain, so closure follows field verification per this workspace's verify-before-close discipline)
Root Cause
In
packages/codev/src/agent-farm/lib/tunnel-client.tsthe tower runs an HTTP/2 server over the tunnel WebSocket. Three defaults combined to cause head-of-line blocking at the session window:http2.createServer({ settings: { enableConnectProtocol: true } })set noinitialWindowSize, so the tower advertised a 65535 B per-stream receive window.'session'handler never calledsetLocalWindowSize(...), so the connection-level receive window stayed at Node's 64 KB default. With a ~150 ms relay↔tower RTT, a 1.3 MB upload exhausts the shared 64 KB window and a ~100 B RPC request can't reach the tower for many round-trips.new WebSocket(...)usedws's defaultperMessageDeflate: true, so large H2 DATA frames were CPU-inflated on the event loop, delaying small outbound frames.Fix
settings.initialWindowSize = TUNNEL_H2_STREAM_WINDOW_SIZE(1 MiB per stream).session.setLocalWindowSize(TUNNEL_H2_SESSION_WINDOW_SIZE)(4 MiB connection window, kept larger than one stream so a big transfer can't consume the whole shared window and block a small RPC).perMessageDeflate: falseon the tunnel WebSocket.Both windows stay under Node's default
maxSessionMemory(10 MB), so no buffer-budget change is needed.Scope note: these raise the tower's inbound windows (relay→tower), which is the half this repo owns and which removes the RPC-request starvation. The relay's own
http2.connect(a separate Railway deployment) must raise its windows to fully fix the outbound reply direction.Test Plan
bugfix-1677-tunnel-h2-window.test.ts): reads the tower's advertised windows back from the mock relay (H2 client) and asserts per-message deflate is not negotiated. Verified it fails at Node's 65535 B defaults and passes with the fix.porch check: build ✓)porch check: tests ✓; existing tunnel suites — 202 tests — green;tsc --noEmitclean)