Skip to content

Commit

Permalink
allow replaying failed txs
Browse files Browse the repository at this point in the history
  • Loading branch information
arcoraven committed Aug 22, 2024
1 parent fdfae42 commit e183cef
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/worker/tasks/sendTransactionWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,22 @@ const handler: Processor<any, void, string> = async (job: Job<string>) => {
job.data,
);

const transaction = await TransactionDB.get(queueId);
let transaction = await TransactionDB.get(queueId);
if (!transaction) {
job.log(`Invalid transaction state: ${stringify(transaction)}`);
return;
}

// The transaction may be errored if it is manually retried.
// For example, the developer retried all failed transactions during an RPC outage.
// An errored queued transaction (resendCount = 0) is safe to retry: the transaction wasn't sent to RPC.
if (transaction.status === "errored" && resendCount === 0) {
transaction = {
...transaction,
status: "queued",
} satisfies QueuedTransaction;
}

// SentTransaction = the transaction or userOp was submitted successfully.
// ErroredTransaction = the transaction failed and should not be re-attempted.
// null = the transaction attemped to resend but was not needed. Ignore.
Expand Down

0 comments on commit e183cef

Please sign in to comment.