Adds an immediate catch to the _send promise passed to _whenReady in case there is rejection before async handlers are added

This commit is contained in:
Nicholas Smith
2019-11-13 01:24:09 -05:00
parent d6757aced2
commit d8dbeedcc2

View File

@@ -382,6 +382,7 @@ class Connection extends EventEmitter {
_whenReady<T>(promise: Promise<T>): Promise<T> {
return new Promise((resolve, reject) => {
promise.catch(reject);
if (!this._shouldBeConnected) {
reject(new NotConnectedError())
} else if (this._state === WebSocket.OPEN && this._isReady) {