fix: Hub lifecycle — wg race, TOCTOU, Go 1.27 - #2
Merged
Merged
Conversation
B1: go.mod updated to Go 1.27 (json/v2 requires it).
B2: wg.Add(1) moved to NewHub() — prevents Close() racing with Run() startup.
B3: Register/Unregister/Broadcast use select with done channel instead of
TOCTOU (RLock→check closed→RUnlock→send). No more panic on closed channel.
Close() no longer closes register/unregister/broadcast channels.
- WebSocket Hub: added 'started' flag — Close() without Run() no longer deadlocks, double Run() returns immediately - SSE Hub: Register/Unregister/Broadcast use select with done channel (double-select pattern: check done first, then try send) - CI: Go 1.25 → 1.27 in all workflows - README: removed 'timeouts' claim (no deadlines implemented yet)
Double Run or Run-after-Close no longer panics. Guard branch returns silently without touching WaitGroup counter. Close without Run returns immediately via started flag.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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 all 3 blockers from Fable 5.1 audit. Validated clean by Fable.