Fix deadlock when UDP port is already in use#58
Conversation
When listenUDP failed silently and FSWatch was disabled, the Run() select loop had no way to receive events — causing a deadlock panic on kill or hanging forever. Now listenUDP signals startup success/failure via a buffered channel; if the port is already bound (watch already running), we return a clear error immediately instead of hanging. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughRun now synchronizes UDP listener startup using a buffered error channel. It waits for the listener to report bind success or an error; on bind failure it returns an error when FSWatch is disabled, or logs a warning and continues when FSWatch is enabled. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/files/daemon.go`:
- Around line 87-94: The current UDP bind error handling assumes every failure
is "address in use"; update the handler where d.listenUDP sends errors to
udpReady (the go routine started with go d.listenUDP(ctx, udpReady)) to inspect
the returned error before emitting the "already in use" message: use
errors.Is(err, syscall.EADDRINUSE) (or equivalent platform-aware check) and only
return the "port already in use — is `supermodel watch` already running?"
message when that specific error matches; for any other error, return or log a
generic "failed to start UDP listener" message including the real error and
include d.cfg.NotifyPort in context and preserve the existing FSWatch fallback
path that logs a warning when FSWatch is active.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d061b9cd-a3f6-4db4-b48d-9e15d46ba2b9
📒 Files selected for processing (1)
internal/files/daemon.go
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
listenUDPnow signals startup success/failure via a buffered channel instead of logging and silently returningRun()returns immediately with a clear error:UDP port 7734 already in use — is supermodel watch already running?Root cause
When the previous watch process left port 7734 bound,
listenUDPreturned early from its goroutine. TheRun()select loop hadctx.Done()as its only exit, but in the test scenario the process was killed — triggering Go's deadlock detector.Test plan
supermodel watch, immediately rerun — should get a clear error instead of hangingsupermodel watchwith no prior instance — starts normallygo test ./internal/files/...passes🤖 Generated with Claude Code
Summary by CodeRabbit