Open DomenicCrypto opened 2 years ago
Would also like to add that the error thrown is uncatchable when surrounding in a try/catch block
@DomenicCrypto I'm running into this issue right now. Have you found a workaround?
It looks like the issue is back; Alchemy WebSocket provider responds with request ID 0 when a request is rate-limited. Here's a sample sequence of responses:
{
"jsonrpc": "2.0",
"id": 112,
"result": "0x0000000000000000000000004976fb03c32e5b8cfe2b6ccb31c09ba78ebaba41"
}
{
"jsonrpc": "2.0",
"id": 0,
"error": {
"code": 429,
"message": "Your app has exceeded its compute units per second capacity. If you have retries enabled, you can safely ignore this message. If not, check out https://docs.alchemy.com/reference/throughput"
}
}
{
"jsonrpc": "2.0",
"id": 124,
"result": "0x000000000000000000000000dad1d029d7ab8142beb1b882c9cad7c02da6a165"
}
I think the solution could be to ignore the errant response — or maybe to handle it with a logger warning rather than an exception. @ricmoo would you open to a patch?
Bump, Strangely, this is happening more often now.
@Quix44 Have you tried v6? A lot of the work in v6 was to abstract the WebSocket (and similar) provider.
In v5, the provider sub-class did not have great deal of flexibility to deal with socket-based providers. This was remedied in v6.
Also happens for me using quicknode
facing the same issue
Describe the bug When creating multiple web socket providers (i.e. via
new ethers.providers.WebSocketProvider()
), the second one always causes a crash.The crash is a
TypeError
and it seems to be coming from the linerequest.callback(null, result.result)
inside@ethersproject\providers\lib\websocket-provider.js:112
.Full stack trace:
To repoduce it you just need to connect to two WebSocketProvider's. I created an isolated test, and this reproduces the bug everytime:
What makes this super strange to me, is that it has been working all week - it just suddenly stopped! I thought I might be rate limited by the service that I am using, but when connecting individually to the seperate websockets my app works fine. Also when reordering them, the first one is always fine.
Environment: I am using a simple NodeJS/Typescript environment, and connecting to Moralis and QuickNode BSC nodes using WSS URLs.
My package.json to see the versions:
I am not sure if I am doing something wrong or dumb, so let me know if I can do something different! Cheers.