Skip to content

Commit e183cef

Browse files
committed
allow replaying failed txs
1 parent fdfae42 commit e183cef

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/worker/tasks/sendTransactionWorker.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,22 @@ const handler: Processor<any, void, string> = async (job: Job<string>) => {
5050
job.data,
5151
);
5252

53-
const transaction = await TransactionDB.get(queueId);
53+
let transaction = await TransactionDB.get(queueId);
5454
if (!transaction) {
5555
job.log(`Invalid transaction state: ${stringify(transaction)}`);
5656
return;
5757
}
5858

59+
// The transaction may be errored if it is manually retried.
60+
// For example, the developer retried all failed transactions during an RPC outage.
61+
// An errored queued transaction (resendCount = 0) is safe to retry: the transaction wasn't sent to RPC.
62+
if (transaction.status === "errored" && resendCount === 0) {
63+
transaction = {
64+
...transaction,
65+
status: "queued",
66+
} satisfies QueuedTransaction;
67+
}
68+
5969
// SentTransaction = the transaction or userOp was submitted successfully.
6070
// ErroredTransaction = the transaction failed and should not be re-attempted.
6171
// null = the transaction attemped to resend but was not needed. Ignore.

0 commit comments

Comments
 (0)