From 80078d9526528c0ee7ed745b75595c7274a907f4 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Thu, 22 Feb 2018 16:23:20 -0800 Subject: [PATCH] fix(Connection): swallow all the ws errors after connection's closed (#2077) Since ws is closing asynchronously and can yield errors while closing, we should keep swallowing ws errors after the `ws.close()` method is called. --- lib/Connection.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Connection.js b/lib/Connection.js index e657926c..0f301d52 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -132,6 +132,8 @@ class Connection extends EventEmitter { this._closeCallback = null; } this._transport.removeAllListeners(); + // If transport throws any error at this point of time, we don't care and should swallow it. + this._transport.on('error', () => {}); for (const callback of this._callbacks.values()) callback.reject(rewriteError(callback.error, `Protocol error (${callback.method}): Target closed.`)); this._callbacks.clear();