@@ -124,6 +124,12 @@ import {
124
124
125
125
declare const TESTING : boolean ;
126
126
127
+ declare const process : {
128
+ env : {
129
+ [ 'DISABLE_MUTATION_RECOVERY' ] ?: string | undefined ;
130
+ } ;
131
+ } ;
132
+
127
133
/**
128
134
* The maximum number of time to call out to getAuth before giving up
129
135
* and throwing an error.
@@ -202,7 +208,7 @@ export class ReplicacheImpl<MD extends MutatorDefs = {}> {
202
208
readonly name : string ;
203
209
204
210
readonly #subscriptions: SubscriptionsManager ;
205
- readonly #mutationRecovery: MutationRecovery ;
211
+ readonly #mutationRecovery: MutationRecovery | undefined ;
206
212
207
213
/**
208
214
* Client groups gets disabled when the server does not know about it.
@@ -475,16 +481,18 @@ export class ReplicacheImpl<MD extends MutatorDefs = {}> {
475
481
const clientGroupIDResolver = resolver < string > ( ) ;
476
482
this . #clientGroupIDPromise = clientGroupIDResolver . promise ;
477
483
478
- this . #mutationRecovery = new MutationRecovery ( {
479
- delegate : this ,
480
- lc : this . #lc,
481
- enableMutationRecovery,
482
- wrapInOnlineCheck : this . #wrapInOnlineCheck. bind ( this ) ,
483
- wrapInReauthRetries : this . #wrapInReauthRetries. bind ( this ) ,
484
- isPullDisabled : this . #isPullDisabled. bind ( this ) ,
485
- isPushDisabled : this . #isPushDisabled. bind ( this ) ,
486
- clientGroupIDPromise : this . #clientGroupIDPromise,
487
- } ) ;
484
+ if ( ! process . env . DISABLE_MUTATION_RECOVERY ) {
485
+ this . #mutationRecovery = new MutationRecovery ( {
486
+ delegate : this ,
487
+ lc : this . #lc,
488
+ enableMutationRecovery,
489
+ wrapInOnlineCheck : this . #wrapInOnlineCheck. bind ( this ) ,
490
+ wrapInReauthRetries : this . #wrapInReauthRetries. bind ( this ) ,
491
+ isPullDisabled : this . #isPullDisabled. bind ( this ) ,
492
+ isPushDisabled : this . #isPushDisabled. bind ( this ) ,
493
+ clientGroupIDPromise : this . #clientGroupIDPromise,
494
+ } ) ;
495
+ }
488
496
489
497
this . #onPersist = initOnPersistChannel (
490
498
this . name ,
@@ -1498,18 +1506,20 @@ export class ReplicacheImpl<MD extends MutatorDefs = {}> {
1498
1506
return ex ;
1499
1507
}
1500
1508
1501
- recoverMutations ( ) : Promise < boolean > {
1502
- const result = this . #mutationRecovery. recoverMutations (
1503
- this . #ready,
1504
- this . perdag ,
1505
- this . #idbDatabase,
1506
- this . #idbDatabases,
1507
- this . #kvStoreProvider. create ,
1508
- ) ;
1509
- if ( TESTING ) {
1510
- void this . onRecoverMutations ( result ) ;
1509
+ recoverMutations ( ) : Promise < boolean > | void {
1510
+ if ( ! process . env . DISABLE_MUTATION_RECOVERY ) {
1511
+ const result = this . #mutationRecovery! . recoverMutations (
1512
+ this . #ready,
1513
+ this . perdag ,
1514
+ this . #idbDatabase,
1515
+ this . #idbDatabases,
1516
+ this . #kvStoreProvider. create ,
1517
+ ) ;
1518
+ if ( TESTING ) {
1519
+ void this . onRecoverMutations ( result ) ;
1520
+ }
1521
+ return result ;
1511
1522
}
1512
- return result ;
1513
1523
}
1514
1524
1515
1525
/**
0 commit comments