Fixed: The memory leak problem that 'websocketprovider' cannot release because 'process' listens to' exit 'events and uses anonymous functions to contain' this'

This commit is contained in:
war1644 2022-04-21 17:55:57 +08:00 committed by GitHub
parent 313c38a2d6
commit 73157ab4b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -281,7 +281,7 @@ export class WebsocketProvider extends Observable {
if (typeof window !== 'undefined') { if (typeof window !== 'undefined') {
window.addEventListener('beforeunload', this._beforeUnloadHandler) window.addEventListener('beforeunload', this._beforeUnloadHandler)
} else if (typeof process !== 'undefined') { } else if (typeof process !== 'undefined') {
process.on('exit', () => this._beforeUnloadHandler) process.on('exit', this._beforeUnloadHandler)
} }
awareness.on('update', this._awarenessUpdateHandler) awareness.on('update', this._awarenessUpdateHandler)
this._checkInterval = /** @type {any} */ (setInterval(() => { this._checkInterval = /** @type {any} */ (setInterval(() => {
@ -320,7 +320,7 @@ export class WebsocketProvider extends Observable {
if (typeof window !== 'undefined') { if (typeof window !== 'undefined') {
window.removeEventListener('beforeunload', this._beforeUnloadHandler) window.removeEventListener('beforeunload', this._beforeUnloadHandler)
} else if (typeof process !== 'undefined') { } else if (typeof process !== 'undefined') {
process.off('exit', () => this._beforeUnloadHandler) process.off('exit', this._beforeUnloadHandler)
} }
this.awareness.off('update', this._awarenessUpdateHandler) this.awareness.off('update', this._awarenessUpdateHandler)
this.doc.off('update', this._updateHandler) this.doc.off('update', this._updateHandler)