Skip to content

node:net: reset the stream state when connect() reuses a half-closed socket - #38980

Open
robobun wants to merge 4 commits into
mainfrom
farm/c5c98b91/net-reconnect-reset-stream-state
Open

node:net: reset the stream state when connect() reuses a half-closed socket#38980
robobun wants to merge 4 commits into
mainfrom
farm/c5c98b91/net-reconnect-reset-stream-state

node:net: one-line comment on the unconditional initSocketHandle call

5314d9e
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Aug 15, 2026 in 31m 8s

Code review found 1 potential issue

Found 1 candidates, confirmed 1. See review comments for details.

Details

Severity Count
🔴 Important 0
🟡 Nit 1
🟣 Pre-existing 0
Severity File:Line Issue
🟡 Nit src/js/node/net.ts:2136-2137 Old-connection events can undo the state reset during hostname resolution

Annotations

Check warning on line 2137 in src/js/node/net.ts

See this annotation in the file changed.

@claude claude / Claude Code Review

Old-connection events can undo the state reset during hostname resolution

The hostname variant of this fix has a race window: `initSocketHandle(this)` resets state synchronously here, but for a non-IP `host` `lookupAndConnect` defers `internalConnect` → `detach_for_reconnect` to an async DNS callback, so the old still-attached connection can deliver `end`/`close` (SocketHandlers2 has no `self.connecting` guard) between the reset and the detach and re-set `kended`/`self.write=writeAfterFIN`/`push(null)`. Not a regression — before this PR the hostname case failed 100% o