Skip to content

Avoid unneeded shutdown timer on already closed connection#125

Merged
clue merged 1 commit intoclue:1.xfrom
clue-labs:endconnection
Apr 14, 2026
Merged

Avoid unneeded shutdown timer on already closed connection#125
clue merged 1 commit intoclue:1.xfrom
clue-labs:endconnection

Conversation

@clue
Copy link
Copy Markdown
Owner

@clue clue commented Apr 14, 2026

This changeset updates the SOCKS server to avoid calling endConnection() when the connection is no longer writable. This avoids creating a useless 3s shutdown timer when the SOCKS handshake fails on a connection that is already closing.

Builds on top of #121

@clue clue added this to the v1.5.0 milestone Apr 14, 2026
@clue clue added the bug Something isn't working label Apr 14, 2026
@clue clue requested a review from Copilot April 14, 2026 11:29
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR prevents the SOCKS server from invoking endConnection() when the incoming connection is no longer writable, avoiding an unnecessary 3s forced-shutdown timer in failure/cancellation scenarios (notably when the client is already closing during handshake).

Changes:

  • Guard endConnection() in Server::onConnection() with ConnectionInterface::isWritable().
  • Update unit tests to stub isWritable() where the rejection path is exercised.
  • Add a regression test covering the “already closed / not writable” scenario.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/Server.php Adds an isWritable() guard before calling endConnection() on SOCKS handshake failure.
tests/ServerTest.php Extends mocks with isWritable() and adds a regression test for the closed-connection failure path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/ServerTest.php
Comment thread tests/ServerTest.php Outdated
@clue clue merged commit cd58a05 into clue:1.x Apr 14, 2026
16 checks passed
@clue clue deleted the endconnection branch April 14, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants