@@ -411,8 +411,12 @@ export class YSocketIO {
411
411
changed = tr . changed . size > 0
412
412
} )
413
413
Y . transact ( existDoc . ydoc , ( ) => {
414
- for ( const msg of updates ) Y . applyUpdate ( existDoc . ydoc , msg )
414
+ for ( const msg of updates ) {
415
+ if ( msg . length === 0 ) continue
416
+ Y . applyUpdate ( existDoc . ydoc , msg )
417
+ }
415
418
for ( const msg of awareness ) {
419
+ if ( msg . length === 0 ) continue
416
420
AwarenessProtocol . applyAwarenessUpdate ( existDoc . awareness , msg , null )
417
421
}
418
422
} )
@@ -429,7 +433,6 @@ export class YSocketIO {
429
433
this . debouncedPersist ( namespace , doc . ydoc )
430
434
this . namespaceDocMap . get ( namespace ) ?. ydoc . destroy ( )
431
435
this . namespaceDocMap . set ( namespace , doc )
432
- await this . client . trimRoomStream ( namespace , 'index' , nsp . sockets . size === 0 )
433
436
}
434
437
435
438
/**
@@ -456,6 +459,7 @@ export class YSocketIO {
456
459
const doc = this . debouncedPersistDocMap . get ( namespace )
457
460
if ( ! doc ) return
458
461
await this . client . store . persistDoc ( namespace , 'index' , doc )
462
+ await this . client . trimRoomStream ( namespace , 'index' , true )
459
463
this . debouncedPersistDocMap . delete ( namespace )
460
464
this . debouncedPersistMap . delete ( namespace )
461
465
} ,
0 commit comments