diff --git a/src/lib/MockWebSocket.ts b/src/lib/MockWebSocket.ts index c1d7bf4..83c70c2 100644 --- a/src/lib/MockWebSocket.ts +++ b/src/lib/MockWebSocket.ts @@ -107,9 +107,9 @@ export class MockWebSocket extends EventEmitter { this.on('message', (message) => duplex.push(message)); - this.on('close', () => duplex.push(null)); + this.once('close', () => duplex.destroy()); - this.on('error', (error) => duplex.destroy(error)); + this.once('error', (error) => duplex.destroy(error)); return duplex; }