reconnecting-websocket
reconnecting-websocket copied to clipboard
Bug: `_handleError` does not bubble up actual error reason (e.g. `ECONNREFUSED`)
As per https://github.com/vitalets/websocket-as-promised/issues/47 we discovered there's a bug in reconnecting-websocket
as well as @opensumi/reconnecting-websocket
:
Needs changed to:
private _handleError = (event: Events.ErrorEvent) => {
this._debug('error event', event.message);
- this._disconnect(undefined, event.message === 'TIMEOUT' ? 'timeout' : undefined);
+ this._disconnect(undefined, event.message === 'TIMEOUT' ? 'timeout' : event.message);
if (this.onerror) {
this.onerror(event);
}
this._debug('exec error listeners');
this._listeners.error.forEach(listener => this._callEventListener(event, listener));
this._connect();
};
Otherwise the err.reason
will be undefined and not bubble up to the error listener, and you won't have a clue as to what happened.
cc @bytemain