Skip to content

Add 90 secs timeout for Manteca payments#1527

Open
Zishan-7 wants to merge 1 commit intodevfrom
fix/manteca-fe-timeout
Open

Add 90 secs timeout for Manteca payments#1527
Zishan-7 wants to merge 1 commit intodevfrom
fix/manteca-fe-timeout

Conversation

@Zishan-7
Copy link
Contributor

@Zishan-7 Zishan-7 commented Dec 4, 2025

No description provided.

@vercel
Copy link

vercel bot commented Dec 4, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
peanut-wallet Ready Ready Preview Comment Dec 4, 2025 1:22pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 4, 2025

Walkthrough

Adds a 90-second timeout mechanism to the QR payment completion flow. On timeout, an error is triggered with user messaging to retry and contact support. Error handling is reorganized, with timeout errors prioritized and additional handling for expired messages. Paying state timer cleanup is maintained with added guards.

Changes

Cohort / File(s) Summary
QR Payment Timeout & Error Handling
src/app/(mobile-ui)/qr-pay/page.tsx
Implements a 90-second timeout around completeQrPaymentWithSignedTx using a race condition. Reorganizes error handling with timeout errors prioritized before nonce-related errors. Updates user-facing error messages for timeout scenarios. Adds handling for expired/stale messages. Maintains paying state timer cleanup on success and error paths with added guards.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Timeout race condition implementation: Verify the Promise.race logic correctly implements the 90-second timeout and that error propagation is handled properly
  • Error handling path ordering: Ensure all error branches (timeout, nonce, expired message, others) are correctly ordered and mutually exclusive
  • State cleanup in all paths: Confirm the paying state timer is cleared in all execution paths (success, timeout, other errors)
  • Control flow integrity: Validate that the reorganized try/catch structure maintains proper post-processing (loading state, error handling, UI updates) across all paths

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess relevance to the changeset. Add a description explaining the rationale for the timeout, what scenarios it addresses, and any testing performed to validate the implementation.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a 90-second timeout mechanism for Manteca QR payments, which is the primary focus of the changeset.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/manteca-fe-timeout

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/app/(mobile-ui)/qr-pay/page.tsx (2)

681-694: Consider reducing the timeout duration for better mobile UX.

The 90-second timeout is quite long for a mobile payment flow. Users typically expect feedback within 30-45 seconds. While the 30-second buffer before the backend's 120-second timeout is good design, consider reducing QR_PAYMENT_TIMEOUT_MS to 45-60 seconds for a more responsive user experience.

Additionally, there's a theoretical race condition if the payment completes just as the timeout fires (e.g., at 89.9s). While your existing state management with setIsSuccess should prevent displaying an error after success, you might want to add an explicit guard in the error handler:

} catch (error) {
    // clear the timer on error to prevent race condition
    if (payingStateTimerRef.current) {
        clearTimeout(payingStateTimerRef.current)
        payingStateTimerRef.current = null
    }
+   // Guard against race condition: don't show error if payment succeeded
+   if (isSuccess) return
+   
    captureException(error)

Based on learnings, payment completion flows in this codebase prioritize UX and feedback timing.


712-726: LGTM! Error handling is well-structured with appropriate prioritization.

The timeout error handling is correctly prioritized first, followed by nonce errors, then expired/stale errors, with a sensible fallback. The error messages provide clear guidance to users.

One minor suggestion: the timeout error message could be more specific about what happened to help users understand the issue better:

if (errorMsg.toLowerCase().includes('timeout')) {
    setErrorMessage(
-       'Could not complete payment. Please scan the QR code again. If problem persists contact support'
+       'Payment took too long to process. Please scan the QR code again. If problem persists contact support'
    )

The addition of expired/stale message handling is a good improvement that fills a gap in the error handling coverage.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 982b824 and bea04fe.

📒 Files selected for processing (1)
  • src/app/(mobile-ui)/qr-pay/page.tsx (2 hunks)
🧰 Additional context used
🧠 Learnings (7)
📚 Learning: 2025-08-22T07:28:32.281Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1104
File: src/components/Payment/PaymentForm/index.tsx:522-545
Timestamp: 2025-08-22T07:28:32.281Z
Learning: In `src/components/Payment/PaymentForm/index.tsx`, the `handleCompleteDaimoPayment` function is only for updating payment status in the backend after a successful Daimo payment. Payment success/failure is handled by Daimo itself, so try/catch error handling and error display are not needed for backend sync failures - users shouldn't see errors if payment succeeded but database update failed.

Applied to files:

  • src/app/(mobile-ui)/qr-pay/page.tsx
📚 Learning: 2025-08-26T15:25:53.328Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1132
File: src/app/[...recipient]/client.tsx:394-397
Timestamp: 2025-08-26T15:25:53.328Z
Learning: In `src/components/Common/ActionListDaimoPayButton.tsx`, the `handleCompleteDaimoPayment` function should not display error messages to users when DB update fails because the Daimo payment itself has succeeded - showing errors would be confusing since the payment was successful.

Applied to files:

  • src/app/(mobile-ui)/qr-pay/page.tsx
📚 Learning: 2025-09-08T03:13:09.111Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 1190
File: src/app/(mobile-ui)/qr-pay/page.tsx:156-176
Timestamp: 2025-09-08T03:13:09.111Z
Learning: In the peanut-ui mobile app, the `/qr-pay` route is only accessed through the DirectSendQR component which always includes the qrCode parameter in the URL when redirecting users to the QR pay page.

Applied to files:

  • src/app/(mobile-ui)/qr-pay/page.tsx
📚 Learning: 2024-11-18T21:36:11.486Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 535
File: src/components/Claim/Claim.tsx:142-146
Timestamp: 2024-11-18T21:36:11.486Z
Learning: In `src/components/Claim/Claim.tsx`, external calls like token price fetching and cross-chain details retrieval are already encapsulated within existing `try...catch` blocks, so additional error handling may be unnecessary.

Applied to files:

  • src/app/(mobile-ui)/qr-pay/page.tsx
📚 Learning: 2024-10-23T09:38:27.670Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 469
File: src/app/request/pay/page.tsx:32-64
Timestamp: 2024-10-23T09:38:27.670Z
Learning: In `src/app/request/pay/page.tsx`, if `linkRes` is not OK in the `generateMetadata` function, the desired behavior is to use the standard title and preview image without throwing an error.

Applied to files:

  • src/app/(mobile-ui)/qr-pay/page.tsx
📚 Learning: 2025-09-08T03:11:00.114Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 1190
File: src/app/(mobile-ui)/qr-pay/page.tsx:31-41
Timestamp: 2025-09-08T03:11:00.114Z
Learning: In QR payment flows, the `createPayment` API call for payment tracking can be non-awaited when called after successful transaction execution, as it's a non-blocking logging operation and doesn't affect the user's success state.

Applied to files:

  • src/app/(mobile-ui)/qr-pay/page.tsx
📚 Learning: 2024-10-07T13:42:07.299Z
Learnt from: Hugo0
Repo: peanutprotocol/peanut-ui PR: 422
File: src/components/Request/Pay/Pay.tsx:113-123
Timestamp: 2024-10-07T13:42:07.299Z
Learning: In the `PayRequestLink` component (`src/components/Request/Pay/Pay.tsx`), when resolving ENS names, handle errors by displaying an appropriate error message to the user if the ENS cannot be resolved.

Applied to files:

  • src/app/(mobile-ui)/qr-pay/page.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Deploy-Preview

@Zishan-7 Zishan-7 requested a review from jjramirezn December 4, 2025 13:21
@notion-workspace
Copy link

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