File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
src/packages/sync/editor/generic Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -1582,7 +1582,7 @@ export class SyncDoc extends EventEmitter {
1582
1582
}
1583
1583
assertDefined ( this . patch_list ) ;
1584
1584
if ( init . size == null ) {
1585
- // don't crash but warn at least.
1585
+ // don't crash but warn at least.
1586
1586
console . warn ( "SYNC BUG -- init.size must be defined" , { init } ) ;
1587
1587
}
1588
1588
if (
@@ -2364,9 +2364,14 @@ export class SyncDoc extends EventEmitter {
2364
2364
} ) ;
2365
2365
2366
2366
// Have a snapshot every this.snapshot_interval patches, except
2367
- // for the very last interval.
2368
- private snapshotIfNecessary = async ( ) : Promise < void > => {
2369
- if ( this . get_state ( ) !== "ready" ) return ;
2367
+ // for the very last interval. Throttle so we don't try to make
2368
+ // snapshots too frequently, as making them is always optional and
2369
+ // now part of the UI.
2370
+ private snapshotIfNecessary = throttle ( async ( ) : Promise < void > => {
2371
+ if ( this . get_state ( ) !== "ready" ) {
2372
+ // especially important due to throttle
2373
+ return ;
2374
+ }
2370
2375
const dbg = this . dbg ( "snapshotIfNecessary" ) ;
2371
2376
const max_size = Math . floor ( 1.2 * MAX_FILE_SIZE_MB * 1000000 ) ;
2372
2377
const interval = this . snapshot_interval ;
@@ -2390,7 +2395,7 @@ export class SyncDoc extends EventEmitter {
2390
2395
} else {
2391
2396
dbg ( "no need to make a snapshot yet" ) ;
2392
2397
}
2393
- } ;
2398
+ } , 60000 ) ;
2394
2399
2395
2400
/*- x - patch object
2396
2401
- patch: if given will be used as an actual patch
You can’t perform that action at this time.
0 commit comments