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({
98
98
QUEUE_FAIL_HISTORY_COUNT : z . coerce . number ( ) . default ( 10_000 ) ,
99
99
// Sets the number of recent nonces to map to queue IDs.
100
100
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 ) ,
101
109
} ,
102
110
clientPrefix : "NEVER_USED" ,
103
111
client : { } ,
@@ -134,6 +142,8 @@ export const env = createEnv({
134
142
QUEUE_COMPLETE_HISTORY_COUNT : process . env . QUEUE_COMPLETE_HISTORY_COUNT ,
135
143
QUEUE_FAIL_HISTORY_COUNT : process . env . QUEUE_FAIL_HISTORY_COUNT ,
136
144
NONCE_MAP_COUNT : process . env . NONCE_MAP_COUNT ,
145
+ EXPERIMENTAL__MINE_WORKER_TIMEOUT_SECONDS :
146
+ process . env . EXPERIMENTAL__MINE_WORKER_TIMEOUT_SECONDS ,
137
147
METRICS_PORT : process . env . METRICS_PORT ,
138
148
METRICS_ENABLED : process . env . METRICS_ENABLED ,
139
149
} ,
Original file line number Diff line number Diff line change 1
1
import { Queue } from "bullmq" ;
2
2
import superjson from "superjson" ;
3
+ import { env } from "../../utils/env" ;
3
4
import { redis } from "../../utils/redis/redis" ;
4
5
import { defaultJobOptions } from "./queues" ;
5
6
6
7
export type MineTransactionData = {
7
8
queueId : string ;
8
9
} ;
9
10
11
+ // Attempts are made every ~20 seconds. See backoffStrategy in initMineTransactionWorker().
12
+ const NUM_ATTEMPTS = env . EXPERIMENTAL__MINE_WORKER_TIMEOUT_SECONDS / 20 ;
13
+
10
14
export class MineTransactionQueue {
11
15
static q = new Queue < string > ( "transactions-2-mine" , {
12
16
connection : redis ,
@@ -23,7 +27,7 @@ export class MineTransactionQueue {
23
27
const jobId = this . jobId ( data ) ;
24
28
await this . q . add ( jobId , serialized , {
25
29
jobId,
26
- attempts : 100 , // > 30 minutes with the backoffStrategy defined on the worker
30
+ attempts : NUM_ATTEMPTS ,
27
31
backoff : { type : "custom" } ,
28
32
} ) ;
29
33
} ;
Original file line number Diff line number Diff line change @@ -162,8 +162,9 @@ const _mineTransaction = async (
162
162
}
163
163
164
164
// Else the transaction is not mined yet.
165
+ const ellapsedMs = Date . now ( ) - sentTransaction . queuedAt . getTime ( ) ;
165
166
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 ` ,
167
168
) ;
168
169
169
170
// Resend the transaction (after some initial delay).
You can’t perform that action at this time.
0 commit comments