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.
This commit is contained in:
Andrey Lushnikov 2018-02-22 16:23:20 -08:00 committed by GitHub
parent 28f88e8ef9
commit 80078d9526
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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();