Skip to content

Report TCP connect failures in the relay window - #210

Merged
Sanjana-Siddani merged 2 commits into
oss-slu:mainfrom
Phlabry:179-tcp-connect-failure
Sep 28, 2026
Merged

Sanjana-Siddani merged 2 commits into
oss-slu:mainfrom
Phlabry:179-tcp-connect-failure

Conversation

@Phlabry

@Phlabry Phlabry commented Sep 27, 2026

Copy link
Copy Markdown
Collaborator

A failed TcpStream::connect in the TCP thread called human_log and exited, so nothing appeared in the GUI. The parent still held tcp_bichannel and tcp_thread_handle, and the guard in tcp_connect rejected every retry with "TCP thread already exists" until Disconnect TCP was pressed.

The thread now sends FromTcpThreadMessage::Disconnected with the reason before bailing. The update handler puts that reason in the error banner, logs it, and calls the new State::reap_tcp_thread to drop the dead handle and channel, so pressing Connect TCP again just works. Polling of the TCP messages moved out of the if-let borrow so the handler can mutate state.

A test connects to a closed port, pumps the Update message the GUI subscription sends, and asserts the surfaced error, the cleared thread handle, the event-log entry, and that a following connect to a live listener succeeds.

The README troubleshooting row no longer tells people to press Disconnect TCP first.

Closes #179

A failed TcpStream::connect only reached stderr, and the parent kept the
dead thread handle, so every later Connect TCP was rejected with "TCP
thread already exists" until Disconnect TCP was pressed. The thread now
sends Disconnected with the reason, the update handler shows it in the
error banner, and reap_tcp_thread clears the dead handle so a retry
works.
@Phlabry
Phlabry requested a review from jmacd867 September 27, 2026 07:24
@Sanjana-Siddani
Sanjana-Siddani requested review from Sanjana-Siddani and removed request for jmacd867 September 28, 2026 04:23

@Sanjana-Siddani Sanjana-Siddani left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hey, nice fix! Sending the failure back as Disconnected and cleaning up the dead thread makes sense. I checked, and that's the only place the thread sends Disconnected, so it can't drop a thread that's still running. It merges fine with main and all 4 relay tests pass, including your retry test.

One thing before merging: the error banner never gets cleared after a successful retry. I extended your test a bit, and after connecting to the working port the banner still said "TCP connection failed: Connection refused" even though TCP was connected. Could you set state.error_message = None when tcp_connect succeeds in connect_tcp_with_validation_and_save? And maybe add assert!(state.error_message.is_none()) after the retry in the test.

Small thing, not blocking: the README row about the IPC socket still says it "gives up silently". That's fixed in #207, so whichever one merges second can update that line.

Will approve after the banner fix

The banner set from FromTcpThreadMessage::Disconnected stayed on screen
after a later connect succeeded, so the window could show "TCP connection
failed: Connection refused" while TCP was connected. tcp_connect now
clears error_message once the thread spawns, which covers both the
Connect TCP button and a saved address picked from the dropdown. The
retry test asserts the banner is gone, and it fails without the change.
@Sanjana-Siddani
Sanjana-Siddani merged commit 047b3bf into oss-slu:main Sep 28, 2026
2 checks passed
@Phlabry
Phlabry deleted the 179-tcp-connect-failure branch October 5, 2026 20:29
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.

Failed TCP connection is silent and blocks all further connection attempts

2 participants