Skip to content

fix(port-forwarding): destroy upstream socket when client disconnects during connect - #305

Merged
harsha509 merged 2 commits into
mainfrom
fix/port-forwarder-early-client-disconnect
Aug 27, 2026
Merged

fix(port-forwarding): destroy upstream socket when client disconnects during connect#305
harsha509 merged 2 commits into
mainfrom
fix/port-forwarder-early-client-disconnect

Conversation

@harsha509

Copy link
Copy Markdown
Collaborator

Fixes a socket leak in DevicePortForwarder. The close and error listeners were attached to the local socket only after the upstream connection resolved. A client disconnect during that window was missed, the upstream socket stayed open and both sockets leaked until stop. An abrupt client reset in the same window also threw an unhandled error event.

Now client close and error are tracked while the upstream connection is being established and the upstream socket is destroyed immediately if the client is already gone. Includes a unit test covering the early disconnect.

Comment thread src/lib/port-forwarding/device-port-forwarder.ts
@harsha509
harsha509 merged commit 957181d into main Aug 27, 2026
9 checks passed
@harsha509
harsha509 deleted the fix/port-forwarder-early-client-disconnect branch August 27, 2026 18:05
github-actions Bot pushed a commit that referenced this pull request Aug 27, 2026
## [5.16.2](v5.16.1...v5.16.2) (2026-08-27)

### Bug Fixes

* **port-forwarding:** destroy upstream socket when client disconnects during connect ([#305](#305)) ([957181d](957181d))
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 5.16.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants