Skip to content

fix(proxies): stop the tunnel before the earner, so a stop that fails halfway is not undone - #640

Closed
GeiserX wants to merge 3 commits into
mainfrom
fix/threads-desktop-stop-order
Closed

GeiserX wants to merge 3 commits into
mainfrom
fix/threads-desktop-stop-order

Conversation

@GeiserX

@GeiserX GeiserX commented Nov 7, 2026

Copy link
Copy Markdown
Owner

Stopping a proxied copy, by hand or at the traffic cap, could be undone by the next heartbeat. proxy_tunnel.stop stopped the earner first, then the tunnel. If the tunnel stop failed, the tunnel stayed up and ready beside a stopped earner. earner_action treats that state as a reboot or crash and starts the earner, so the stop was lost. The same window opened for a moment on every successful stop, between the two calls, whenever a heartbeat ran in it.

The fix reverses the order: the tunnel stops first, then the earner. If the tunnel stop fails, nothing has stopped and the error reaches the UI. If the earner stop fails after the tunnel stopped, the earner has no way out, as the "It fails closed" section of docs/proxies.md describes and scripts/proxy_leak_test.sh proves. earner_action leaves it alone because the tunnel is not running.

Tests:

  • test_stop_takes_the_tunnel_before_its_earner replaces the test that pinned the old order.
  • test_a_stop_that_fails_halfway_is_not_undone_by_the_heartbeat makes each stop fail in turn and checks that the heartbeat would not start the earner. The tunnel-fails case fails on main.

The same fix for Desktop is GeiserX/CashPilot-Desktop#262, from the review of Desktop #245, which ported this code.

…p is not undone

proxy_tunnel.stop stopped the earner first. When the tunnel stop then failed,
the next heartbeat found a ready tunnel beside a stopped earner and started the
earner again, losing the stop. The tunnel now stops first; an earner left
running without its tunnel has no way out and the heartbeat leaves it alone.
Same fix as CashPilot-Desktop's stopProxied.
@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 26 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 d709e47 and 82615ae.

Files selected for processing: 2

  • app/proxy_tunnel.py
  • tests/test_proxy_tunnel.py
  • 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 93.96%. Comparing base (d709e47) to head (82615ae).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #640      +/-   ##
==========================================
- Coverage   93.97%   93.96%   -0.01%     
==========================================
  Files          74       74              
  Lines       15678    15678              
==========================================
- Hits        14733    14732       -1     
- Misses        945      946       +1     
Files with missing lines Coverage Δ
app/proxy_tunnel.py 88.76% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 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.

@GeiserX

GeiserX commented Nov 7, 2026

Copy link
Copy Markdown
Owner Author

Landed in #653 (f681889), which combined this fix with the others into one release.

@GeiserX GeiserX closed this Nov 7, 2026
@GeiserX
GeiserX deleted the fix/threads-desktop-stop-order branch November 7, 2026 21:41
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