{"record":{"id":"f937b187b6141b92","repo":"slymnoyann/hey-1","slug":"transaction-confirmation-timed-out","errorCode":null,"errorMessage":"Transaction confirmation timed out","messagePattern":"Transaction confirmation timed out","errorType":"exception","errorClass":"TransactionWaitError","httpStatus":null,"severity":"error","filePath":"src/hooks/useWaitForTransactionToComplete.tsx","lineNumber":44,"sourceCode":"        const { data } = await getTransactionStatus({\n          variables: { request: { txHash: hash } }\n        });\n\n        const status = data?.transactionStatus;\n\n        if (status?.__typename === \"FinishedTransactionStatus\") {\n          return;\n        }\n\n        if (status?.__typename === \"FailedTransactionStatus\") {\n          throw new TransactionWaitError(status.reason);\n        }\n\n        await new Promise((resolve) => setTimeout(resolve, delay));\n        delay = Math.min(delay * 2, MAX_DELAY);\n      }\n\n      throw new TransactionWaitError(\"Transaction confirmation timed out\");\n    },\n    [getTransactionStatus]\n  );\n\n  return waitForTransactionToComplete;\n};\n\nexport default useWaitForTransactionToComplete;\n","sourceCodeStart":26,"sourceCodeEnd":53,"githubUrl":"https://github.com/slymnoyann/hey-1/blob/88c8f9d55340d57a37846ff72f55c2c604e3a566/src/hooks/useWaitForTransactionToComplete.tsx#L26-L53","documentation":"Thrown as TransactionWaitError by useWaitForTransactionToComplete when a exponential-backoff polling loop (delay doubling up to MAX_DELAY) exhausts its attempts without the transaction reaching a confirmed status via getTransactionStatus. It's a timeout, not a rejection: the tx may still confirm later.","triggerScenarios":"A slow or congested chain where the tx takes longer than the loop's total budget; the tx hash not yet visible to the status RPC/indexer (node lag, indexer behind head); RPC endpoint flakiness returning pending/unknown; or the tx actually reverted and never reaches 'success' status.","commonSituations":"Gas spikes or NFT mint congestion on Polygon; using a free RPC with slow finality propagation; a reorg invalidating the observed hash; API indexer (Lens Hub indexer) lagging behind the chain so status stays pending.","solutions":["Retry with the same hash: waiting is idempotent and the tx often confirms on a second pass","Switch to a more reliable/faster RPC endpoint or official chain RPC for getTransactionStatus","Verify the tx on a block explorer by hash before retrying — if it reverted, surface a revert error instead of looping","Increase MAX_DELAY/attempt budget for congested periods, or use wagmi's waitForTransactionReceipt which subscribes instead of polling"],"exampleFix":"// before\nthrow new TransactionWaitError(\"Transaction confirmation timed out\");\n\n// after: include the hash and make it retryable\nclass TransactionWaitError extends Error {\n  constructor(public txHash: string) {\n    super(`Transaction ${txHash} confirmation timed out`);\n  }\n}\nthrow new TransactionWaitError(hash);","handlingStrategy":"retry","validationCode":"// Check status on an explorer/RPC before waiting, to catch already-final or reverted txs\nconst receipt = await publicClient.getTransactionReceipt({ hash });\nif (receipt) {\n  if (receipt.status === \"reverted\") throw new Error(\"Transaction reverted\");\n  return; // already confirmed\n}","typeGuard":"const isTransactionWaitError = (e: unknown): e is Error & { name: \"TransactionWaitError\" } =>\n  e instanceof Error && e.message === \"Transaction confirmation timed out\";","tryCatchPattern":"try {\n  await waitForTransactionToComplete(hash);\n} catch (e) {\n  if (isTransactionWaitError(e)) {\n    // timeout != failure: check explorer by hash; retry the wait once\n    await sleep(5000);\n    return waitForTransactionToComplete(hash);\n  }\n  throw e;\n}","preventionTips":["Treat timeout as 'unknown status', never as a guaranteed failure — verify by hash on an explorer","Use a reliable RPC and consider wagmi waitForTransactionReceipt (subscription) over polling","Increase the backoff budget during known congestion; surface the tx hash to the user so they can track it"],"tags":["transaction","blockchain","timeout","polling","rpc"],"backgroundTag":"transaction-confirmation-timeout","analyzedSha":"88c8f9d55340d57a37846ff72f55c2c604e3a566","analyzedAt":"2026-08-28T16:20:43.640Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}