fix(daemon): throttle OpenCode capture retries for dead server ports#404
Open
fix(daemon): throttle OpenCode capture retries for dead server ports#404
Conversation
Implement per-run backoff for message capture failures, especially connection refused errors from stale OpenCode server endpoints. Key changes: - Add exponential backoff (10s -> 60s cap) for capture failures - Apply stricter backoff (2x multiplier) for ECONNREFUSED specifically - Track capture failure state per-run (count, timestamps, last error) - Rate-limit/deduplicate logs (first error + different errors only) - Reset backoff on successful capture This reduces connection refused spam to bounded, periodic logs and avoids tight retry loops against known-dead endpoints. Fixes: orch-427
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
Motivation
Connection refused errors from stale OpenCode server ports created high-volume log noise and unnecessary retry load when daemon monitoring attempted message capture against older runs whose servers had stopped.
Changes
internal/daemon/daemon.goRunStatestruct with capture backoff state fields:CaptureFailCount- tracks consecutive failuresLastCaptureFailAt- when last failure occurredNextCaptureRetryAt- backoff deadlineLastCaptureError- for log deduplicationinternal/daemon/monitor.goshouldSkipCapture()- skips capture during backoff periodhandleCaptureError()- sets backoff and logs first/new errors onlyresetCaptureBackoff()- clears state on successful capturecalculateCaptureBackoff()- exponential backoff with ECONNREFUSED boostisConnectionRefused()- detects connection refused via net.OpError or stringinternal/daemon/monitor_test.goshouldSkipCapture,calculateCaptureBackoff,handleCaptureError,resetCaptureBackoff,isConnectionRefusedAcceptance Criteria Evidence
shouldSkipCapture()enforcesNextCaptureRetryAtdeadline.resetCaptureBackoff()clears state on success; no changes to successful path.Fixes: orch-427