Skip to content

fix(proxies): start a copy the cap released even when its first start fails - #271

Merged
GeiserX merged 2 commits into
mainfrom
fix/retry-capped-copy-start
Nov 7, 2026
Merged

GeiserX merged 2 commits into
mainfrom
fix/retry-capped-copy-start

Conversation

@GeiserX

@GeiserX GeiserX commented Nov 7, 2026

Copy link
Copy Markdown
Owner

When a proxy's cap lifts (a reset, or the cap raised or turned off), each copy the cap stopped gets one start. If that start fails, for example because Docker is restarting or the proxy is not answering yet, the copy keeps its "stopped by the cap" mark and nothing tries again until the next reset, which can be a month away.

A second path had the same problem. The cap lifts while a stop is on its way and the start back fails. That copy was left stopped with no mark, so even the next reset would not start it.

The fix follows the idea of GeiserX/CashPilot#637 (retry on the next heartbeat), adapted to Desktop, which has one machine and a once-a-minute pass instead of box heartbeats:

  • ProxyTick now retries every copy that still carries the cap's mark on each pass where its proxy is not capped. A copy that starts loses the mark, so it is not started again. A Start or Stop by hand clears the mark, as before.
  • Only the first attempt records the failure as an event. Retries run every minute, and each *_error event takes 20 points off the service's health score.
  • The mid-stop path marks the copy when its start back fails, so the next pass picks it up.
  • docs/proxies.md says the app retries every minute instead of waiting for the next reset.

Tests, in internal/services/proxies_test.go:

  • TestACappedCopyThatDidNotStartIsRetriedEveryPass and TestACopyWhoseStartBackFailedMidStopIsRetried both failed on main (the copy stayed stopped) and pass here.
  • Recording the event on every retry (a deliberate mutation) makes the first test fail with "2 start-error events".
  • go test -race ./internal/services/ ./internal/runtime/ passes.

Web: #637 covers the same gap there.

…tarts

A copy whose start failed when the cap lifted kept its mark and waited for
the next reset, up to a month. The once-a-minute pass now retries every
marked copy of an uncapped proxy, recording the failure only once. The
mid-stop path marks the copy when its start back fails, so it is retried
too instead of staying stopped with no mark.
@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 8b9cada and e4b6d45.

Files selected for processing: 3

  • docs/proxies.md
  • internal/services/proxies.go
  • internal/services/proxies_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.34%. Comparing base (8b9cada) to head (e4b6d45).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #271      +/-   ##
==========================================
+ Coverage   77.29%   77.34%   +0.04%     
==========================================
  Files          81       81              
  Lines       12565    12565              
==========================================
+ Hits         9712     9718       +6     
+ Misses       2048     2044       -4     
+ Partials      805      803       -2     
Files with missing lines Coverage Δ
internal/services/proxies.go 66.35% <100.00%> (+1.12%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

#268 on main already retries a cap-stopped copy every pass, under the copy lock.
Keep that implementation and carry over what this branch adds to it: a retry
that keeps failing is not an event every minute, and a start back that fails
after the cap lifted mid-stop marks the copy so the next pass starts it. The
branch's two tests run against main's code; the fake provider keeps both sides' hooks.
@GeiserX
GeiserX merged commit b6ac5e3 into main Nov 7, 2026
9 checks passed
@GeiserX
GeiserX deleted the fix/retry-capped-copy-start branch November 7, 2026 23:49
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