Repository navigation
Conversation
raymondk
added this pull request to stack #835
October 20, 2026 15:44
raymondk
force-pushed
the
cycles-buy/06-wait-clock
branch
from
October 20, 2026 15:45
8e7c8b2 to
8e00aa9
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The overall one-hour timeout remains unenforced during an outage spanning that deadline.
1 open issue
What changed in this PR
Makes icp cycles buy detect gateway outages and bound waits without changing the order flow.
Changes:
- Adds poll timeouts and clock-based outage detection.
- Reports lost and restored contact, preserving the last known order on failure.
- Adds timing tests, an integration test, and documentation.
| File | Description |
|---|---|
| docs/guides/tokens-and-cycles.md | Documents outage warnings and wait limits. |
| crates/icp-cli/tests/cycles_tests.rs | Tests gateway stop/restart reporting. |
| crates/icp-cli/src/cyclepay/tests.rs | Tests outage timing, recovery, and timeout behavior. |
| crates/icp-cli/src/cyclepay/purchase.rs | Adds timed polling and connectivity events. |
| crates/icp-cli/src/commands/cycles/buy.rs | Displays connectivity changes and failure context. |
| CHANGELOG.md | Records the wait reliability improvements. |
Review effort: Balanced
| select! { | ||
| biased; | ||
| _ = interrupt.as_mut() => return Step::Interrupted, | ||
| _ = sleep_until(give_up_at) => return Step::GaveUp, |
raymondk
force-pushed
the
cycles-buy/06-wait-clock
branch
2 times, most recently
from
October 20, 2026 18:48
a5ed15f to
94b912e
Compare
…of the order The wait polled the gateway every three seconds with no time limit of its own on a poll, so a stalled connection held it for the HTTP client's six minutes; the give-up rule counted a hundred consecutive failed polls, which took five minutes on a network that refuses and ten hours on one that stalls; and the hour limit was only checked after a successful poll, so it never fired while the gateway was unreachable. Now a poll gets ten seconds, and after five minutes without word of the order the wait gives up with `ContactLost`, carrying the order as last seen over the last poll's failure. Both that and the hour are judged on the clock after every poll, answered or not. Still a query every three seconds; nothing else about the order changes. Code by Josh, cut down from #824 (commit 9cd3e1c, wait part only). Not included: the live line saying the gateway has gone quiet and is answering again, and the events that drove it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015aem4tPs4TYVZb8k4LMbJJ
raymondk
force-pushed
the
cycles-buy/06-wait-clock
branch
from
October 20, 2026 19:34
94b912e to
f880802
Compare
raymondk
removed this pull request from stack #835
October 20, 2026 19:40
raymondk
added this pull request to stack #838
October 20, 2026 19:40
This branch has not been deployed
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.

The wait polled the gateway every three seconds, and its limits did not hold while the gateway was out of reach. A single poll had only the HTTP client's limit, six minutes, so a connection that stalled rather than dropped held the live line at "Waiting for payment" that long. The give-up rule counted a hundred consecutive failed polls: five minutes on a network that refuses at once, but about ten hours on one that stalls. And the hour limit was checked only after a successful poll, so it never fired while the gateway was unreachable.
Now a poll gets 10 seconds, and after five minutes without word of the order the wait gives up with
ContactLost, which carries the order as last seen over the last poll's failure, so the command can say where the order stands. Both the give-up and the hour are judged on the clock after every poll, answered or not. Still a query every three seconds; nothing else about the order changes. Ctrl-C still lands at any moment, as before.Code by Josh, cut down from #824 (commit 9cd3e1c, wait part only):
WaitOptions { poll_interval, poll_timeout, give_up_after, timeout },PollTimedOutandContactLosterrors. Not included, after review: the live line saying the gateway has gone quiet and is answering again, and theWaitEventcallback that drove it. A user who sees nothing for a while can Ctrl-C, and #831 then says where the order stands.Tests: four clock-driven unit tests in
cyclepay/tests.rs(a stalled network given up on after five minutes with the poll timeout as the cause, a refusing one with the refusal, an order gone for five minutes not found, a gateway back within five minutes carried on with) and the hour still holding on an unpaid order.Part of restacking #824 into small PRs, one fix each, stacked on
mainin this order:cycles-buy/06-wait-clock→07-follow-up→08-json-fields. Each PR targets the one below it; after the one below merges, retarget tomain.🤖 Generated with Claude Code
https://claude.ai/code/session_015aem4tPs4TYVZb8k4LMbJJ