Skip to content

fix: close client tunnel relay when the target ends the channel - #9

Merged
LukeGus merged 1 commit into
Termix-SSH:dev-1.3.0from
zyjohn-design:fix/client-tunnel-target-eof
Nov 7, 2026
Merged

LukeGus merged 1 commit into
Termix-SSH:dev-1.3.0from
zyjohn-design:fix/client-tunnel-target-eof

Conversation

@zyjohn-design

Copy link
Copy Markdown

Fixes #8

Client tunnels left the desktop's local socket open after the target closed its side of the connection. Browsers reused that dead keep-alive connection, so the next request stayed pending forever. One example: the LiteLLM login after its 5-second idle timeout.

The relay in c2s-relay.ts now also closes the WebSocket when the outbound SSH channel emits end. Before, it only closed on close and error. The existing close handler then destroys the channel, and the desktop closes the local socket. This matches how ssh -D behaves.

Validation:

  • New test in tests/backend/c2s-relay.test.ts half-closes the outbound stream of a LOCAL tunnel and expects the relay to close. It fails without the change and passes with it.
  • npm test (153 passed), tsc -p ., npm run validate, npm run format:check.
  • Applied the same change to a running Termix server. Through a DYNAMIC tunnel, an idle connection to LiteLLM now gets EOF after 5 s instead of never, and the login request returns normally.

This is independent of #7, which fixes the desktop-side first-data race.

@termix-triage-bot

Copy link
Copy Markdown

AI review | Looks safe to merge

Adds an end event listener to the outbound SSH channel stream to propagate half-closed connections to the WebSocket, fixing browser keep-alive hangs. The change is minimal, includes a targeted test, and follows all repo rules.

Reviewed f6f4f43. AI can be wrong, a maintainer still decides. Comment /termix review to run it again.

@LukeGus
LukeGus changed the base branch from main to dev-1.3.0 November 7, 2026 03:16
@LukeGus
LukeGus merged commit 4afd15d into Termix-SSH:dev-1.3.0 Nov 7, 2026
2 checks passed
LukeGus added a commit that referenced this pull request Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Client tunnels keep the local connection open after the target closes it, so reused requests hang

2 participants