Unable to catch this Ethers using Infura sockets bug

0|itokenbo | Error: request failed or timed out
0|itokenbo |     at WebSocketProvider._this._websocket.onmessage (/opt/bitnami/apache/htdo
cs/node_modules/@ethersproject/providers/lib/websocket-provider.js:123:33)
0|itokenbo |     at WebSocket.onMessage (/opt/bitnami/apache/htdocs/node_modules/ws/lib/ev
ent-target.js:132:16)
0|itokenbo |     at WebSocket.emit (events.js:326:22)
0|itokenbo |     at Receiver.receiverOnMessage (/opt/bitnami/apache/htdocs/node_modules/ws
/lib/websocket.js:834:20)
0|itokenbo |     at Receiver.emit (events.js:314:20)
0|itokenbo |     at Receiver.dataMessage (/opt/bitnami/apache/htdocs/node_modules/ws/lib/r
eceiver.js:437:14)
0|itokenbo |     at /opt/bitnami/apache/htdocs/node_modules/ws/lib/receiver.js:394:23
0|itokenbo |     at /opt/bitnami/apache/htdocs/node_modules/ws/lib/permessage-deflate.js:3
08:9
0|itokenbo |     at /opt/bitnami/apache/htdocs/node_modules/ws/lib/permessage-deflate.js:3
91:7
0|itokenbo |     at afterWrite (_stream_writable.js:490:5) {
0|itokenbo |   code: -32603,
0|itokenbo |   response: '{"jsonrpc":"2.0","id":629060,"error":{"code":-32603,"message":"r
equest failed or timed out"}}'
0|itokenbo | }

I’ve tried:

provider._websocket.on('close')

provider._websocket.on('message')

provider._websocket.on('error')

provider._websocket.on('end')

But the intermittent bug, one that’s caused by on-chain reads and not writes, keeps slipping by.

Any ideas please?

Thanks

Hey, no idea, it should be caught by error or close
I suggest getting this to the ethers team WebSocketProvider handle ws close and reconnect · Issue #1053 · ethers-io/ethers.js · GitHub