Repository navigation
fix(ssh): exit closes the tab instead of reconnecting (#538) - #566
Merged
Merged
Conversation
The close event went out on the server's EOF, before the exit-status that marks a deliberate exit. RouterOS sends EOF, exit-status, CLOSE in that order, so `/quit` read as a dropped link and the tab reconnected. Only CLOSE (or the end of the stream) settles the channel now; an exit-status anywhere before it counts. Persistent sessions on hosts without a multiplexer wrapper (Windows, dropbear) run a plain shell, but the frontend still treated them as persistent and reconnected on every exit. The backend now decides: a wrapped session's clean exit probes the multiplexer on the live connection, so a detach still reattaches while an `exit` ends the tab at once, without the reconnect-then-SESSION_ENDED detour. The attach probe shares the same helper.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #538.
Causes
channel_ioemittedssh-closedon the server's EOF, before the exit-status that marks a deliberate exit. Traced on a real RouterOS 7.23.7 (CHR):/quitsends EOF → exit-status → CLOSE, so it read as a dropped link and reconnected.persiston Windows hosts (and when the wrapper exceeds dropbear's limit), but the frontend still treated the tab as persistent, skipped the clean-exit path and reconnected to a plain shell — with no attach probe to stop it.Fix
CloseWatch).persistent_session_present.remoteExitnow means "ended" and closes the tab regardless ofpersist; persistent tabs are also tombstoned. Linux persistentexitno longer shows the 2–3 s reconnect checklist before closing.Verification
Live, private headless container with this build:
/quit, persist offexit, persist offexit, persist onUnit tests for both message orders and a drop;
reconnectBackofftests; tsc;cargo fmt --check;cargo clippy --all-targets -D warnings.Not run on a Windows host: relies on Windows OpenSSH sending exit-status before CLOSE (shared OpenSSH session code). Cause 2 is fixed regardless.