diff --git a/packages/framework/store/src/store/collection.ts b/packages/framework/store/src/store/collection.ts index 86c2f3858344..464bfca16aa7 100644 --- a/packages/framework/store/src/store/collection.ts +++ b/packages/framework/store/src/store/collection.ts @@ -234,6 +234,10 @@ export class DocCollection extends DocCollectionAddonType { return this.getDoc(docId, { query }) as Doc; } + dispose() { + this.awarenessStore.destroy(); + } + /** * Terminate the data sync process forcefully, which may cause data loss. * It is advised to invoke `canGracefulStop` before calling this method. diff --git a/packages/framework/store/src/yjs/awareness.ts b/packages/framework/store/src/yjs/awareness.ts index 31c434645ee0..1ff6db7f4aac 100644 --- a/packages/framework/store/src/yjs/awareness.ts +++ b/packages/framework/store/src/yjs/awareness.ts @@ -94,10 +94,8 @@ export class AwarenessStore { } destroy() { - if (this.awareness) { - this.awareness.off('change', this._onAwarenessChange); - this.slots.update.dispose(); - } + this.awareness.off('change', this._onAwarenessChange); + this.slots.update.dispose(); } getFlag(field: Key) {