Repository navigation
fix(browser): settle WSL tunnel reads so responses past 256 KiB complete - #27625
Conversation
The WSL execution route hands the deferred socket a credit-accounted tunnel duplex, but the deferred socket forwarded its data without settling it, so the relay's 256 KiB receive window was never replenished and larger responses stalled. Settle each chunk once tunnel-socket listeners have taken it; their pause() still holds the source, so unsettled bytes stay bounded by the window. Fixes #27356
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to No actionable merge-blocking issue remains in the reviewed change. The WSL response path returns read credit while retaining bounded backpressure. Pre-merge checks |
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
2fe3c51a-0d54-48dd-a003-f68788e6f90b
📒 Files selected for processing (3)
src/main/browser/browser-network-deferred-socket.test.tssrc/main/browser/browser-network-deferred-socket.tssrc/main/browser/wsl-browser-network-execution-route.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
ELI5
A browser opened from a paired device in a WSL project froze on any page or file bigger than 256 KiB. Those responses now finish.
What Changed
The WSL route wraps each tunnel stream in
BrowserNetworkDeferredSocket. That socket passeddataon but never called the inner tunnel'ssettleRead. The tunnel only lets the WSL relay send more after the receiver confirms ("settles") the bytes it already took. So after the first 256 KiB window the relay stopped sending, and the page hung.The deferred socket now calls
source.settleRead?.(bytes.byteLength)right after handing each chunk to its listeners.Why
The deferred socket is the adapter between two contracts:
pause().Confirming at that boundary keeps backpressure intact. When a reader pauses, the source stops emitting, so nothing more is confirmed and unconfirmed bytes stay capped at one window. Both readers already pause when full: the tunnel session, and the local-route
Duplex, which pauses whenpush()returns false.I rejected passing the settle step through the shared socket interface into the tunnel session. That would touch every plain-socket destination for nothing, since the session's own buffer is already capped.
The fix is host-only. It sends the existing
WindowUpdateframe that older relays already understand, so nothing changes on the wire. SSH routes are unaffected: an ssh2 channel has nosettleReadand manages its own window, so the optional call does nothing there. The paired-runtime route already settles throughpipeUpstreamToClient.Linked Issue
Fixes #27356
Visual Proof
N/A: this is flow control in the main process with no UI change. The real tunnel session, client and WSL route are covered by tests.
Testing
New tests:
All three fail on
mainand stop at exactly 262144 bytes, matching the issue. With the fix, the deferred-socket, WSL-route, SSH-route and conformance test files pass (28/28).I also made the existing fake relay behave like a real pipe: it now uses the relay's real frame writer and delivers asynchronously, so a credit update can't re-enter before the sent data is counted.
pnpm tc:node,oxlintandcheck:code-quality:changedare clean.Checklist
N/Awith reason