@@ -491,16 +491,14 @@ onboard_logging.initialize = function (callback) {
491
491
show_saving_dialog ( ) ;
492
492
493
493
const MAX_SIMPLE_RETRIES = 5 ;
494
- const RETRY_BACKOFF_MS = 30 ; // ms
494
+ const BASE_RETRY_BACKOFF_MS = 30 ; // base backoff in ms
495
495
const startTime = new Date ( ) . getTime ( ) ;
496
496
497
497
prepare_file ( ( fileWriter ) => {
498
498
FileSystem . openFile ( fileWriter ) . then ( ( file ) => {
499
499
openedFile = file ;
500
-
501
500
let nextAddress = 0 ;
502
501
503
- // Queue-based read function
504
502
function readNextBlock ( ) {
505
503
if ( saveCancelled || nextAddress >= maxBytes ) {
506
504
mark_saving_dialog_done ( startTime , nextAddress , totalBytesCompressed ) ;
@@ -516,6 +514,7 @@ onboard_logging.initialize = function (callback) {
516
514
self . blockSize ,
517
515
( chunkAddress , chunkDataView , bytesCompressed ) => {
518
516
if ( chunkDataView && chunkDataView . byteLength > 0 ) {
517
+ // Good block
519
518
simpleRetryCount = 0 ;
520
519
521
520
const blob = new Blob ( [ chunkDataView ] ) ;
@@ -530,7 +529,6 @@ onboard_logging.initialize = function (callback) {
530
529
531
530
$ ( ".dataflash-saving progress" ) . attr ( "value" , ( nextAddress / maxBytes ) * 100 ) ;
532
531
533
- // Continue with next block
534
532
readNextBlock ( ) ;
535
533
} else if ( chunkDataView && chunkDataView . byteLength === 0 ) {
536
534
// Zero-length block → EOF
@@ -540,17 +538,20 @@ onboard_logging.initialize = function (callback) {
540
538
// Null/missing block
541
539
if ( simpleRetryCount < MAX_SIMPLE_RETRIES ) {
542
540
simpleRetryCount ++ ;
541
+ const backoff = BASE_RETRY_BACKOFF_MS * simpleRetryCount ;
542
+
543
543
if ( simpleRetryCount % 2 === 1 ) {
544
544
console . warn (
545
- `Null/missing block at ${ nextAddress } , retry ${ simpleRetryCount } ` ,
545
+ `Null/missing block at ${ nextAddress } , retry ${ simpleRetryCount } , backoff ${ backoff } ms ` ,
546
546
) ;
547
547
}
548
- setTimeout ( attemptRead , RETRY_BACKOFF_MS ) ;
548
+
549
+ setTimeout ( attemptRead , backoff ) ;
549
550
} else {
550
551
console . error (
551
552
`Skipping null block at ${ nextAddress } after ${ MAX_SIMPLE_RETRIES } retries` ,
552
553
) ;
553
- nextAddress += self . blockSize ;
554
+ nextAddress += self . blockSize ; // skip block
554
555
readNextBlock ( ) ;
555
556
}
556
557
}
0 commit comments