fix(wallet-cli): retry sendCommand only on ECONNREFUSED - #9608
Merged
Merged
Conversation
The daemon client's `sendCommand` retried a request once on both ECONNREFUSED and ECONNRESET. ECONNRESET can drop after the daemon has already received and acted on the request, so blindly re-sending a non-idempotent request (e.g. a transaction broadcast) could execute it twice. Restrict the retry to ECONNREFUSED — where the connection was never established, so the daemon provably never received the request — and surface ECONNRESET to the caller instead. This hardens the retry path before any mutating send/sign/transfer RPC becomes reachable over the daemon socket. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
sirtimid
marked this pull request as ready for review
July 22, 2026 16:19
sirtimid
enabled auto-merge
July 22, 2026 16:20
rekmarks
approved these changes
Jul 22, 2026
3 tasks done
This branch was previously 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.
Explanation
wallet-cli's daemon clientsendCommandretried a failed request once on bothECONNREFUSEDandECONNRESET. OnlyECONNREFUSEDis safe to retry — it means the connection was never established, so the daemon never received the request.ECONNRESETcan drop after the daemon received and acted on the request, so a blind resend could execute a non-idempotent action (e.g. broadcast a transaction) twice.This restricts the retry to
ECONNREFUSED;ECONNRESETnow surfaces to the caller (wheremakeDaemonConnectionErroralready renders a distinct "lost the connection to the daemon" message). Updates thesendCommandandPingUnreachableReasonJSDoc accordingly.Latent today (all current callers are idempotent), but a prerequisite for shipping any send/sign/transfer command.
References
wallet-cli: makesendCommandretry idempotency-safe before mutating RPC ships #9511wallet-cli: add themmsend-transaction command #9513Checklist
Note
Medium Risk
Changes daemon RPC failure semantics in a wallet CLI path that will back send/sign flows; the tradeoff is correct for safety but callers may see more surfaced connection errors instead of silent retries.
Overview
Narrows daemon JSON-RPC client retry behavior so
sendCommandretries once only onECONNREFUSED, not onECONNRESET. A reset can happen after the daemon already handled the request, so a blind resend could run a non-idempotent action (e.g. broadcast) twice; those errors now propagate to callers instead.pingDaemonstill classifiesECONNRESETas unreachable with reasonrefused, but inherits the no-retry rule viasendCommand. JSDoc, changelog, and tests were updated to match.Reviewed by Cursor Bugbot for commit 1fa26b8. Bugbot is set up for automated code reviews on this repo. Configure here.