File tree Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,14 @@ export const env = createEnv({
9898 QUEUE_FAIL_HISTORY_COUNT : z . coerce . number ( ) . default ( 10_000 ) ,
9999 // Sets the number of recent nonces to map to queue IDs.
100100 NONCE_MAP_COUNT : z . coerce . number ( ) . default ( 10_000 ) ,
101+
102+ /**
103+ * Experimental env vars. These may be renamed or removed in future non-major releases.
104+ */
105+ // Sets how long the mine worker waits for a transaction receipt before considering the transaction dropped (default: 30 minutes).
106+ EXPERIMENTAL__MINE_WORKER_TIMEOUT_SECONDS : z . coerce
107+ . number ( )
108+ . default ( 30 * 60 ) ,
101109 } ,
102110 clientPrefix : "NEVER_USED" ,
103111 client : { } ,
@@ -134,6 +142,8 @@ export const env = createEnv({
134142 QUEUE_COMPLETE_HISTORY_COUNT : process . env . QUEUE_COMPLETE_HISTORY_COUNT ,
135143 QUEUE_FAIL_HISTORY_COUNT : process . env . QUEUE_FAIL_HISTORY_COUNT ,
136144 NONCE_MAP_COUNT : process . env . NONCE_MAP_COUNT ,
145+ EXPERIMENTAL__MINE_WORKER_TIMEOUT_SECONDS :
146+ process . env . EXPERIMENTAL__MINE_WORKER_TIMEOUT_SECONDS ,
137147 METRICS_PORT : process . env . METRICS_PORT ,
138148 METRICS_ENABLED : process . env . METRICS_ENABLED ,
139149 } ,
Original file line number Diff line number Diff line change 11import { Queue } from "bullmq" ;
22import superjson from "superjson" ;
3+ import { env } from "../../utils/env" ;
34import { redis } from "../../utils/redis/redis" ;
45import { defaultJobOptions } from "./queues" ;
56
67export type MineTransactionData = {
78 queueId : string ;
89} ;
910
11+ // Attempts are made every ~20 seconds. See backoffStrategy in initMineTransactionWorker().
12+ const NUM_ATTEMPTS = env . EXPERIMENTAL__MINE_WORKER_TIMEOUT_SECONDS / 20 ;
13+
1014export class MineTransactionQueue {
1115 static q = new Queue < string > ( "transactions-2-mine" , {
1216 connection : redis ,
@@ -23,7 +27,7 @@ export class MineTransactionQueue {
2327 const jobId = this . jobId ( data ) ;
2428 await this . q . add ( jobId , serialized , {
2529 jobId,
26- attempts : 100 , // > 30 minutes with the backoffStrategy defined on the worker
30+ attempts : NUM_ATTEMPTS ,
2731 backoff : { type : "custom" } ,
2832 } ) ;
2933 } ;
Original file line number Diff line number Diff line change @@ -162,8 +162,9 @@ const _mineTransaction = async (
162162 }
163163
164164 // Else the transaction is not mined yet.
165+ const ellapsedMs = Date . now ( ) - sentTransaction . queuedAt . getTime ( ) ;
165166 job . log (
166- `Transaction is not mined yet. Check again later. sentTransactionHashes =${ sentTransaction . sentTransactionHashes } ` ,
167+ `Transaction is not mined yet. Check again later. elapsed =${ ellapsedMs / 1000 } s ` ,
167168 ) ;
168169
169170 // Resend the transaction (after some initial delay).
You can’t perform that action at this time.
0 commit comments