-
Notifications
You must be signed in to change notification settings - Fork 5k
node:net: reset the stream state when connect() reuses a half-closed socket #38980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
edad317
44e6a05
33e982c
5314d9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2122,8 +2122,6 @@ | |
| } | ||
| if (this.destroyed) { | ||
| this._handle = null; | ||
| this._peername = null; | ||
| this._sockname = null; | ||
| } | ||
|
|
||
| this.connecting = true; | ||
|
|
@@ -2134,8 +2132,9 @@ | |
|
|
||
| if (!this._handle) { | ||
| this._handle = newDetachedSocket(typeof this[bunTlsSymbol] === "function"); | ||
| initSocketHandle(this); | ||
| } | ||
| // A reused handle gets a new connection from doConnect, so it is reset as well. | ||
| initSocketHandle(this); | ||
|
Check warning on line 2137 in src/js/node/net.ts
|
||
|
Comment on lines
+2136
to
+2137
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 The hostname variant of this fix has a race window: Extended reasoning...What the gap is
The code path that re-corrupts the reset stateDuring that DNS window the old (still-attached) connection can deliver its FIN or close to
The Why the existing tests don't cover itEvery new test in this PR — the rewritten "should allow reconnecting after end()" and all four "connect() while the previous connection is half-closed" cases — connects to Step-by-step trace
Why this is a nit, not a blocker
Per REVIEW.md's "Cover the variant matrix, not just the repro" this is worth noting — the hostname variant is an untested gap — but not worth blocking a PR that fixes the flaky test it set out to fix and strictly improves every case. |
||
|
|
||
| if (!pipe) { | ||
| lookupAndConnect(this, options); | ||
|
|
@@ -4261,10 +4260,11 @@ | |
| return arr; | ||
| } | ||
|
|
||
| // Called when creating new Socket, or when re-using a closed Socket | ||
| // Called on every connect(): a new Socket, or one re-used for another connection. | ||
| function initSocketHandle(self) { | ||
| self._undestroy(); | ||
| self._sockname = null; | ||
| self._peername = null; | ||
| self[kclosed] = false; | ||
| self[kended] = false; | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.