From 95bf3f3ea8b6fbaa6f092a5447974463f07a3e3f Mon Sep 17 00:00:00 2001 From: Gus Narea Date: Wed, 28 Jul 2021 20:37:54 +0100 Subject: [PATCH] feat: Close writable stream too when it's closed --- src/lib/MockWebSocket.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; }