Skip to content

fix(CI): retry on transient wallet desync during commit#1570

Merged
TheLastCicada merged 1 commit into
v2-rc2from
fix/retry-transient-wallet-desync
Apr 7, 2026
Merged

fix(CI): retry on transient wallet desync during commit#1570
TheLastCicada merged 1 commit into
v2-rc2from
fix/retry-transient-wallet-desync

Conversation

@TheLastCicada

@TheLastCicada TheLastCicada commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Summary

After org creation, the wallet temporarily desyncs while processing a burst of on-chain confirmations (store creation, mirror adds, data pushes). Two code paths failed instantly with no retry, causing spurious live API test failures:

  1. Server-side (src/utils/data-assertions.js): assertWalletIsAvailable in the middleware rejected non-GET requests immediately when walletIsSynced() returned false — even for transient desync. Now retries up to 5 times (25s total) when the wallet is reachable but temporarily not synced, while still failing fast on connection errors (ECONNREFUSED etc.).

  2. Test-side (tests/{v1,v2}/live-api/helpers/live-api-helpers.js): commitStagedRecords threw on the first non-200 response with no retry. Now retries up to 5 times (50s total) when the commit fails due to wallet availability/sync errors, matching the retry pattern already used in org creation tests.

Root cause from CI run #2429

  • V1 org creation triggered ~10 on-chain transactions
  • Wallet temporarily desynced processing confirmations
  • POST /v1/staging/commit hit middleware, assertWalletIsAvailable failed in 16ms
  • Wallet recovered 5 seconds later (confirmed by end-of-job wallet check)
  • Both the server and test had zero tolerance for this predictable transient condition

Test plan

  • V1 live API tests pass (the exact job that failed)
  • V2 live API tests pass (same fix applied)
  • V1 and V2 integration tests still pass (simulator mode skips wallet checks)
  • Connection errors (ECONNREFUSED) still fail fast on the server side

Note

Medium Risk
Adds retry/backoff behavior to wallet availability checks and V1 live-api commit helper, which can change request latency and error timing when the wallet is unhealthy. Scope is limited to wallet gating and test helpers, but it affects a core prerequisite for write operations.

Overview
Reduces flaky failures when the Chia wallet is temporarily desynced after bursts of on-chain activity by adding bounded retries instead of failing immediately.

On the server, assertWalletIsAvailable now distinguishes connection failures from transient sync lag and retries walletIsAvailable() up to 5 times (5s delay) before throwing. In V1 live API tests, commitStagedRecords now retries POST /v1/staging/commit up to 5 times (10s delay) only when responses look like wallet availability/sync errors; V2’s commit helper is left without an extra wrapper since its request layer already retries.

Reviewed by Cursor Bugbot for commit 8390ac9. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e675a9a. Configure here.

Comment thread src/utils/data-assertions.js
Comment thread tests/v2/live-api/helpers/live-api-helpers.js Outdated
After org creation, the wallet temporarily desyncs while processing
on-chain confirmations. The middleware assertWalletIsAvailable check
and test commitStagedRecords both failed instantly with no retry,
causing spurious CI failures.

Server-side: assertWalletIsAvailable now retries up to 5 times (25s)
when the wallet is reachable but not synced, while still failing fast
on connection errors (checked on every retry iteration).

Test-side (V1): commitStagedRecords retries up to 5 times (50s) on
wallet availability/sync errors before giving up. V2 already has
createRetryableRequest at the transport layer handling this, so the
V2 commitStagedRecords is left unchanged.
@TheLastCicada TheLastCicada force-pushed the fix/retry-transient-wallet-desync branch from e675a9a to 8390ac9 Compare April 7, 2026 17:42
@TheLastCicada TheLastCicada merged commit 91b1f37 into v2-rc2 Apr 7, 2026
25 checks passed
@TheLastCicada TheLastCicada deleted the fix/retry-transient-wallet-desync branch April 7, 2026 18:38
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