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

Crash on invalid WebSocket response #2379

Closed
1 task done
dcposch opened this issue Jun 9, 2024 · 2 comments
Closed
1 task done

Crash on invalid WebSocket response #2379

dcposch opened this issue Jun 9, 2024 · 2 comments
Labels
needs reproduction Misc: Needs Reproduction

Comments

@dcposch
Copy link

dcposch commented Jun 9, 2024

Check existing issues

Viem Version

1.21.4

Current Behavior

Node process occasionally crashes when using reactContract with a websocket transport.

The error is likely triggered by invalid server server responses. We're using QuickNode.

However, I don't see a way to catch this error in user code since it occurs in Viem's internal WS message handler. The error is not passed back to readContract caller. Note how entire call stack is native code > viem:

[VIEM] request 84532 eth_getBlockByNumber

TypeError: Cannot read properties of null (reading 'method')
    at WebSocket.onMessage (/Users/dc/code/daimo/node_modules/viem/utils/rpc.ts:185:40)
    at WebSocket.[nodejs.internal.kHybridDispatch] (node:internal/event_target:816:20)
    at WebSocket.dispatchEvent (node:internal/event_target:751:26)
    at fireEvent (node:internal/deps/undici/undici:10966:14)
    at websocketMessageReceived (node:internal/deps/undici/undici:10988:7)
    at ByteParser.run (node:internal/deps/undici/undici:11439:17)
    at ByteParser._write (node:internal/deps/undici/undici:11315:14)
    at writeOrBuffer (node:internal/streams/writable:564:12)
    at _write (node:internal/streams/writable:493:10)
    at ByteParser.Writable.write (node:internal/streams/writable:502:10)

Node.js v22.2.0

Expected Behavior

RPC response errors should be passed back to the caller.

Steps To Reproduce

Intermittent issue, probably triggered by bad RPC responses.

Anything else?

No response

@tmm tmm added the needs reproduction Misc: Needs Reproduction label Jun 9, 2024
Copy link
Contributor

github-actions bot commented Jun 9, 2024

Hello @dcposch.

Please provide a minimal reproduction using StackBlitz, TypeScript Playground (for type issues), or a separate minimal GitHub repository.

Minimal reproductions are required as they save us a lot of time reproducing your config/environment and issue, and allow us to help you faster.

Once a minimal reproduction is added, a team member will confirm it works, then re-open the issue.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 9, 2024
Copy link
Contributor

This issue has been locked since it has been closed for more than 14 days.

If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Viem version. If you have any questions or comments you can create a new discussion thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs reproduction Misc: Needs Reproduction
Projects
None yet
Development

No branches or pull requests

2 participants