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

WebSocket provider does not correctly handle WebSocket issues #4616

Open
mkykadir opened this issue Feb 21, 2024 · 0 comments
Open

WebSocket provider does not correctly handle WebSocket issues #4616

mkykadir opened this issue Feb 21, 2024 · 0 comments
Assignees
Labels
investigate Under investigation and may be a bug. v5 Issues regarding legacy-v5

Comments

@mkykadir
Copy link

Ethers Version

5.7.2

Search Terms

websocker,provider

Describe the Problem

When underlying WebSocket library emits an "error" message this is not correctly propagated to upper levels, thus it creates unhandled rejections.

defineReadOnly(this, "_websocket", new WebSocket(this.connection.url));

the issue can be resolved with following;

if (typeof(url) === "string") {
    var _ws = new WebSocket(this.connection.url);
    _ws.on("error", (error) => this.emit("error", error));
    defineReadOnly(this, "_websocket", _ws);
}

Code Snippet

new WebSocketProvider("<a wss url returns 502">");

Contract ABI

No response

Errors

No response

Environment

No response

Environment (Other)

No response

@mkykadir mkykadir added investigate Under investigation and may be a bug. v5 Issues regarding legacy-v5 labels Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Under investigation and may be a bug. v5 Issues regarding legacy-v5
Projects
None yet
Development

No branches or pull requests

2 participants