File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -165,18 +165,21 @@ const _mineTransaction = async (
165165 }
166166
167167 // Else the transaction is not mined yet.
168- const ellapsedMs = Date . now ( ) - sentTransaction . queuedAt . getTime ( ) ;
168+ const elapsedSeconds = msSince ( sentTransaction . sentAt ) / 1000 ;
169169 job . log (
170- `Transaction is not mined yet. Check again later. elapsed=${ ellapsedMs / 1000 } s` ,
170+ `Transaction is not mined yet. Check again later. elapsed=${ elapsedSeconds } s` ,
171171 ) ;
172172
173- // Resend the transaction (after some initial delay) .
173+ // Resend the transaction if `minEllapsedBlocksBeforeRetry` blocks or 120 seconds have passed since the last send attempt .
174174 const config = await getConfig ( ) ;
175175 const blockNumber = await getBlockNumberish ( sentTransaction . chainId ) ;
176- const ellapsedBlocks = blockNumber - sentTransaction . sentAtBlock ;
177- if ( ellapsedBlocks >= config . minEllapsedBlocksBeforeRetry ) {
176+ const elapsedBlocks = blockNumber - sentTransaction . sentAtBlock ;
177+ const shouldResend =
178+ elapsedBlocks >= config . minEllapsedBlocksBeforeRetry ||
179+ elapsedSeconds > 120 ;
180+ if ( shouldResend ) {
178181 job . log (
179- `Resending transaction after ${ ellapsedBlocks } blocks. blockNumber=${ blockNumber } sentAtBlock=${ sentTransaction . sentAtBlock } ` ,
182+ `Resending transaction after ${ elapsedBlocks } blocks. blockNumber=${ blockNumber } sentAtBlock=${ sentTransaction . sentAtBlock } ` ,
180183 ) ;
181184 await SendTransactionQueue . add ( {
182185 queueId : sentTransaction . queueId ,
You can’t perform that action at this time.
0 commit comments