Skip to content

fix(tunnel): queue chunks that arrive mid-dial instead of dialing again - #14

Merged
vercel-eddie merged 3 commits into
mainfrom
eddie/tunnel-pending-conn
Sep 8, 2026
Merged

fix(tunnel): queue chunks that arrive mid-dial instead of dialing again#14
vercel-eddie merged 3 commits into
mainfrom
eddie/tunnel-pending-conn

Conversation

@vercel-eddie

@vercel-eddie vercel-eddie commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

vercel-eddie and others added 3 commits September 8, 2026 13:08
The tunnel has no explicit open message: the first data chunk for an
unknown connection ID is what opens it, and the receiving side only
registered the ID after its dial returned. Any further chunk for that ID
arriving during the dial (Node's HTTP/2 client sends the preface and the
first request frames ~1-2ms apart) spawned another dial for the same
connection, splitting the stream across two sockets. The peer saw a
preface on one socket and headers on the other and simply never
answered, so the caller hung until its own deadline instead of getting
an error.

Register a buffering placeholder for the ID synchronously on the recv
pump, dial off the pump, then swap the real connection in and flush the
queued chunks in order. A peer error that lands while the dial is in
flight now also closes the dialed socket instead of leaking it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Replace the tunnel-private pendingConn with a reusable
BufferedReadWriteCloser in pkg/ioutil: an io.ReadWriteCloser that
buffers writes until Set attaches the underlying one, then flushes them
as a single write and passes everything through.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel-eddie
vercel-eddie marked this pull request as ready for review September 8, 2026 20:47
@vercel-eddie
vercel-eddie merged commit 678df96 into main Sep 8, 2026
6 checks passed
@vercel-eddie
vercel-eddie deleted the eddie/tunnel-pending-conn branch September 8, 2026 20:52
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