Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: _handleError does not bubble up actual error reason (e.g. ECONNREFUSED) #198

Open
titanism opened this issue Jul 2, 2024 · 0 comments

Comments

@titanism
Copy link

titanism commented Jul 2, 2024

As per vitalets/websocket-as-promised#47 we discovered there's a bug in reconnecting-websocket as well as @opensumi/reconnecting-websocket:

https://github.com/opensumi/reconnecting-websocket/blob/6010e6b99967c2977c7abc7d0a1845245c101eb2/reconnecting-websocket.ts#L478-L489

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant