ethers.js icon indicating copy to clipboard operation
ethers.js copied to clipboard

WS Subscriptions are not awaited, thus errors cannot be handled

Open mkykadir opened this issue 10 months ago • 0 comments

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

https://github.com/ethers-io/ethers.js/blob/0bfa7f497dc5793b66df7adfb42c6b846c51d794/packages/providers/src.ts/websocket-provider.ts#L248-L256

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 avatar Apr 08 '24 10:04 mkykadir