Skip to content

Track forwarded tunnel connections by socket - #347033

Merged
Alex Ross (alexr00) merged 2 commits into
microsoft:mainfrom
sameerihs:track-tunnel-connections-by-socket
Nov 11, 2026
Merged

Alex Ross (alexr00) merged 2 commits into
microsoft:mainfrom
sameerihs:track-tunnel-connections-by-socket

Conversation

@sameerihs

Copy link
Copy Markdown
Contributor

Fixes #347032

Related to microsoft/vscode-remote-release#2237.

Connections on the same tunnel listener share localAddress, so the disposal map retains only the most recent callback. Key it by socket identity and remove each socket's entry on close. Existing registration guards and graceful shutdown remain.

The regression fixture opens/closes the actual tunnel service, completes the real protocol handshake over ephemeral loopback sockets and exchanges data before teardown. A single-connection control passes on base; two concurrent connections and disconnecting one before stopping forwarding fail. All 31 selected checks pass after the fix.

Client compilation/typecheck and targeted lint, including explicit lint for the new fixture, pass. The 1.145.2 implementation is identical. Pending-handshake disposal and a packaged workbench/remote-host scenario are outside the validation claim.

Copilot AI balanced review requested due to automatic review settings November 9, 2026 16:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the socket-identity-based tunnel connection cleanup change.

No open issues 🎉

What changed in this PR

Fixes #347032 by tracking built-in Node tunnel connections by socket identity, so stopping port forwarding closes all established connections rather than only the newest one.

Changes:

  • Keys disposal callbacks by socket and removes each entry on close.
  • Adds regression coverage for single and concurrent connections, including disconnecting one before stopping forwarding.
  • Adds an isolated loopback fixture using the real protocol handshake and data exchange.
File Description
src/​vs/​platform/​tunnel/​test/​node/​tunnelService.test.ts Adds three connection-cleanup regression cases using a child-process fixture.
src/​vs/​platform/​tunnel/​test/​node/​fixtures/​tunnelServiceConnection.ts Exercises tunnel shutdown over loopback sockets with real handshakes and data exchange.
src/​vs/​platform/​tunnel/​node/​tunnelService.ts Tracks disposal callbacks by socket identity and deletes entries on close.

Review effort: Balanced

@alexr00 Alex Ross (alexr00) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@alexr00
Alex Ross (alexr00) enabled auto-merge (squash) November 11, 2026 16:20
@alexr00
Alex Ross (alexr00) merged commit 31d8840 into microsoft:main Nov 11, 2026
52 of 53 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.147.0 milestone Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants