Skip to content

fix(swap): forward underlying tx error to Vercel and replace "dropped by network" copy#139

Merged
passandscore merged 2 commits into
mainfrom
dropped-by-network-errors
Apr 27, 2026
Merged

fix(swap): forward underlying tx error to Vercel and replace "dropped by network" copy#139
passandscore merged 2 commits into
mainfrom
dropped-by-network-errors

Conversation

@passandscore
Copy link
Copy Markdown
Contributor

Summary

  • The three error paths in useWaitForTxConfirmation (wagmi receiptError, plus the two mctransactions.status='failed' poll paths) all built a new Error("Transaction X was dropped by the network.") and threw away the original error context. Vercel logs got the generic message and nothing else — no viem shortMessage/details/metaMessages, no cause chain, no row details from the DB.
  • This PR keeps each thrown Error friendly to the user ("Swap Failed, please try again") while preserving every diagnostic field so reportClientError forwards them to Vercel.

Changes

  • src/app/api/fast-tx-status/[hash]/route.ts — query now also returns details; response shape is { status, details }.
  • src/lib/fast-tx-status.tsfetchFastTxStatus returns { status, details } so the hook can forward the simulation reason.
  • src/hooks/use-wait-for-tx-confirmation.ts
    • New buildSwapFailedError(cause, fallbackDetails?) helper. Sets message = "Swap Failed, please try again" and copies cause, viem shortMessage/details/metaMessages/walk, and the original stack onto the wrapper.
    • Wagmi receiptError path uses it (passes the original viem error as cause).
    • Both DB-poll failed paths use it (passes mctransactions.details as fallbackDetails).
    • The literal "Transaction X was dropped by the network." string is removed.

What Vercel sees now

  • Wagmi path: payload.message = "Swap Failed, please try again" + payload.viem.shortMessage/details/metaMessages/rootCauseName/rootCauseMessage populated from the original viem error + original stack.
  • DB-poll path: payload.message = "Swap Failed, please try again" + payload.viem.details = <mctransactions.details> (e.g. selector 0x553b7dda, TRANSFER_FROM_FAILED, nonce too high, status 500).

Test plan

  • Manually trigger a wagmi-detected drop (slow node / disconnect) and confirm Vercel log contains viem fields.
  • Manually trigger a sim failure (intentional bad permit / stale quote) and confirm Vercel log contains the mctransactions.details string.
  • Confirm the toast UI now reads "Swap Failed, please try again" in both cases.
  • npx vitest run — all 50 tests pass locally.
  • npx tsc --noEmit — clean.

… by network" copy

Three error paths in useWaitForTxConfirmation previously threw a new
Error with a generic "dropped by the network" message and no other
context, so the wagmi/viem cause chain and the mctransactions row's
details column were lost in Vercel logs.

- /api/fast-tx-status/[hash] now also returns the row's details.
- fetchFastTxStatus returns { status, details } so the hook can
  forward the underlying simulation reason.
- buildSwapFailedError() wraps the original error in a friendly
  "Swap Failed, please try again" message while preserving cause,
  viem shortMessage/details/metaMessages/walk, and the original stack
  so reportClientError forwards them verbatim.
- Wagmi receiptError path and both DB-poll failure paths now use the
  same wrapper. The "dropped by the network" string is removed.
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 27, 2026

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

Project Deployment Actions Updated (UTC)
fastprotocolapp Ready Ready Preview, Comment Apr 27, 2026 6:31pm

Request Review

@passandscore passandscore merged commit d384975 into main Apr 27, 2026
3 checks passed
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