Retry Telegram photo mints on nonce race with a friendly notice#411
Conversation
createMomentBatch is already serialized per smart wallet, but a concurrent UserOperation from an unprotected call site can still occasionally trigger AA25 invalid account nonce. Instead of failing the mint outright, notify the user once and retry up to 3 attempts, 5s apart, before giving up.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughAdds nonce error classification and a bounded retry wrapper for Coinbase minting. Group moment creation now uses the wrapper, which posts one Telegram notification before delayed retries. New tests cover classification, success, retry, non-retryable, and exhausted-retry paths. ChangesNonce retry flow
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant createMomentsFromGroup
participant mintWithNonceRetry
participant createMomentBatch
participant TelegramThread
createMomentsFromGroup->>mintWithNonceRetry: Pass thread and batch input
mintWithNonceRetry->>createMomentBatch: Create moment batch
createMomentBatch-->>mintWithNonceRetry: Return nonce error
mintWithNonceRetry->>TelegramThread: Post busy retry notification
mintWithNonceRetry->>mintWithNonceRetry: Wait five seconds
mintWithNonceRetry->>createMomentBatch: Retry batch creation
createMomentBatch-->>mintWithNonceRetry: Return result or final error
mintWithNonceRetry-->>createMomentsFromGroup: Return result or rethrow error
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
src/lib/coinbase/__tests__/isNonceRetryableError.test.tsOops! Something went wrong! :( ESLint: 9.39.4 TypeError: Converting circular structure to JSON ... [truncated 446 characters] ... c/dist/eslintrc.cjs:3261:25) src/lib/coinbase/isNonceRetryableError.tsOops! Something went wrong! :( ESLint: 9.39.4 TypeError: Converting circular structure to JSON ... [truncated 446 characters] ... c/dist/eslintrc.cjs:3261:25) src/lib/telegram/chat/moment/__tests__/mintWithNonceRetry.test.tsOops! Something went wrong! :( ESLint: 9.39.4 TypeError: Converting circular structure to JSON ... [truncated 446 characters] ... c/dist/eslintrc.cjs:3261:25)
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. Comment |
Summary
AA25 invalid account noncewhen a concurrent UserOperation races the same smart wallet's nonce (thecreateMomentBatchpath is already lock-protected, but other unprotectedsendUserOperationcall sites can still collide with it).isNonceRetryableErrorto detect AA25/nonce-related failures, andmintWithNonceRetryto wrapcreateMomentBatch: on a nonce error it posts a one-time friendly "network's busy" notice to the chat and retries up to 3 attempts total, 5s apart, before giving up.createMomentsFromGroup.tsnow goes throughmintWithNonceRetryinstead of callingcreateMomentBatchdirectly.Test plan
pnpm vitest runforisNonceRetryableError,mintWithNonceRetry,createMomentsFromGroup— 16 tests passtsc --noEmitshows no new type errors from these filesSummary by CodeRabbit
New Features
Tests