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

WS Subscriptions are not awaited, thus errors cannot be handled #4683

Open
mkykadir opened this issue Apr 8, 2024 · 0 comments
Open

WS Subscriptions are not awaited, thus errors cannot be handled #4683

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

Comments

@mkykadir
Copy link

mkykadir commented Apr 8, 2024

Ethers Version

5.7.2

Search Terms

websocket, provider

Describe the Problem

Subscription to an event, i.e. newheads and logs may end up with error on provider side; since subscription is not awaited, errors cannot be handled and drops to "unhandled promise rejection"

Following _subscribes within _startEvent should be awaited

_startEvent(event: Event): void {
switch (event.type) {
case "block":
this._subscribe("block", [ "newHeads" ], (result: any) => {
const blockNumber = BigNumber.from(result.number).toNumber();
this._emitted.block = blockNumber;
this.emit("block", blockNumber);
});
break;

Code Snippet

No response

Contract ABI

No response

Errors

Unhandled Rejection: [object Promise], Error: Unsupported subcription: logs

Environment

node.js (v12 or newer)

Environment (Other)

No response

@mkykadir mkykadir added investigate Under investigation and may be a bug. v5 Issues regarding legacy-v5 labels Apr 8, 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