diff --git a/packages/provider/src/HocuspocusProvider.ts b/packages/provider/src/HocuspocusProvider.ts index ea0eef55..5d7681fb 100644 --- a/packages/provider/src/HocuspocusProvider.ts +++ b/packages/provider/src/HocuspocusProvider.ts @@ -511,7 +511,10 @@ export class HocuspocusProvider extends EventEmitter { this.configuration.websocketProvider.off('destroy', this.configuration.onDestroy) this.configuration.websocketProvider.off('destroy', this.forwardDestroy) - this.send(CloseMessage, { documentName: this.configuration.name }) + if (!this.configuration.preserveConnection) { + this.send(CloseMessage, { documentName: this.configuration.name }) + } + this.disconnect() if (typeof window === 'undefined' || !('removeEventListener' in window)) {