Skip to content

Cap how long monitoring can run - #9

Merged
Gabriel-Lewis merged 1 commit into
fix/album-sibling-migrationfrom
fix/monitor-max-runtime
Aug 30, 2026
Merged

Gabriel-Lewis merged 1 commit into
fix/album-sibling-migrationfrom
fix/monitor-max-runtime

Conversation

@Gabriel-Lewis

Copy link
Copy Markdown
Owner

Audit finding 3.

Stacked on #7 — the cap has to bound the release-migration retry loop too, and that only exists there. Base is fix/album-sibling-migration; it retargets to dev automatically once #7 merges. #8 also touches monitor.go, so whichever of the three lands last needs a small rebase.

The bug

SLSKD_MONITOR_DURATION (15 min) only gives up on a download that has stopped moving — monitor.go resets its clock on any increase in bytes transferred. A transfer trickling in a few bytes per tick resets it forever.

Because the playlist is built after monitoring returns, one slow peer could hold back all 50 tracks indefinitely, with nothing bounding the loop.

The fix

SLSKD_MONITOR_MAX_RUNTIME caps the whole pass, defaulting to 120 minutes. On expiry the monitor stops and returns without an error, so the playlist is still built from whatever finished — only tracks still in flight are lost, which is already what happens to a skipped track. 0 disables the cap.

Documented in both sample.env files. Note that its siblings (SLSKD_MONITOR_INTERVAL, SLSKD_MONITOR_DURATION) aren't documented there either; I only added the new one rather than expanding scope.

Testing

  • A download that inches forward forever now stops at the limit. Mutation-checked: with the cap disabled the test fails with MonitorDownloads never returned; the time limit did not apply after hanging the full 5s timeout.
  • A normal run finishes untouched by the cap.
  • 0 disables it, verified across several ticks so a zero deadline can't be mistaken for "already expired".

go build ./..., go vet ./src/..., go test ./src/... pass.

🤖 Generated with Claude Code

SLSKD_MONITOR_DURATION only gives up on a download that has stopped
moving: any increase in bytes transferred resets its clock. A transfer
trickling in a few bytes per tick therefore resets it forever, and since
the playlist is built after monitoring returns, one slow peer could hold
back all fifty tracks with nothing to bound it.

SLSKD_MONITOR_MAX_RUNTIME caps the pass as a whole, defaulting to two
hours. On expiry the monitor stops and returns without an error, so the
playlist is still built from whatever finished; only the tracks still in
flight are lost, which is what already happens to a skipped track. 0
disables the cap for anyone who would rather wait.

The cap also bounds the release migration added alongside it, since that
is checked inside the same loop.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Gabriel-Lewis
Gabriel-Lewis merged commit f661b68 into fix/album-sibling-migration Aug 30, 2026
@Gabriel-Lewis
Gabriel-Lewis deleted the fix/monitor-max-runtime branch October 19, 2026 22:56
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.

1 participant