Repository navigation
Free a preview port slot when a forwarded connection errors - #384
Closed
minutechreview wants to merge 1 commit into
Closed
minutechreview wants to merge 1 commit into
minutechreview wants to merge 1 commit into
Conversation
Signed-off-by: minutechreview <141821420+minutechreview@users.noreply.github.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
In the loopback port forwarder,
error()setsocket.data.closed = truewithout lowering the listener's connection count. Whenclose()ran next, it sawclosedand returned early, so the count stayed at 1 andsweep()never closed that listener. Enough errored connections and a machine runs out of its 64 preview port slots.backend/src/runners/loopback.ts: onereleaseConnectionhelper marks the socket closed, lowers the count and bumpslastActivity, and only does this once per socket.close()anderror()both call it.close()still ends the link stream,error()still resets it.backend/src/runners/loopback.test.ts: new case that drives a socket throughopen,error, thenclose(theBun.listenhandlers are captured withspyOn), moves the clock pastFORWARDER_IDLE_MS, and expectssweep()to close the listener.Testing:
bun test src/runners/loopback.test.ts: 4 pass. Withloopback.tsfrommain, the new case fails (sweep()returns 0, expected 1).bun test src/runners src/runs/terminal.test.ts: 58 pass.tsc --noEmit(TypeScript 5.9.3) is clean.Fixes #304
Need help on this PR? Tag
@codesmith-botwith what you need.