Fix log stream dying silently across WiFi mode switches - #107
Merged
Conversation
Two real bugs found live-testing on the board: - streamLog() never checked for client disconnection, so the handler (and its tail follower) ran forever even after the client was long gone - one leaked goroutine per dropped EventSource connection. - Confirmed by reproducing #95 directly: when the board's WiFi interface disappears mid-stream (switching AP/station mode), the connection goes completely silent on both ends - no RST, no read error, nothing. Neither side's error handling ever fires, so the client just waits forever with a "dead" connection that never reports itself as dead. Fixes: streamLog() now watches the request context and returns (and stops its tail follower) once the client disconnects. It also sends a 15s heartbeat event, and the client watches for it with a 30s watchdog - if nothing arrives in time, it assumes the connection is dead and reconnects itself rather than waiting on an onerror that may never come. Closes #95
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.
Summary
Closes #95
Test plan
go test ./...andbats test/batspass🤖 Generated with Claude Code