fix(swap): forward underlying tx error to Vercel and replace "dropped by network" copy#139
Merged
Merged
Conversation
… 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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
… please try again'
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.
Summary
useWaitForTxConfirmation(wagmireceiptError, plus the twomctransactions.status='failed'poll paths) all built a newError("Transaction X was dropped by the network.")and threw away the original error context. Vercel logs got the generic message and nothing else — no viemshortMessage/details/metaMessages, no cause chain, no row details from the DB."Swap Failed, please try again") while preserving every diagnostic field soreportClientErrorforwards them to Vercel.Changes
src/app/api/fast-tx-status/[hash]/route.ts— query now also returnsdetails; response shape is{ status, details }.src/lib/fast-tx-status.ts—fetchFastTxStatusreturns{ status, details }so the hook can forward the simulation reason.src/hooks/use-wait-for-tx-confirmation.tsbuildSwapFailedError(cause, fallbackDetails?)helper. Setsmessage = "Swap Failed, please try again"and copiescause, viemshortMessage/details/metaMessages/walk, and the original stack onto the wrapper.cause).failedpaths use it (passesmctransactions.detailsasfallbackDetails)."Transaction X was dropped by the network."string is removed.What Vercel sees now
payload.message = "Swap Failed, please try again"+payload.viem.shortMessage/details/metaMessages/rootCauseName/rootCauseMessagepopulated from the original viem error + original stack.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
mctransactions.detailsstring.npx vitest run— all 50 tests pass locally.npx tsc --noEmit— clean.