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

WebSocket watchBlocks with emitOnBegin: true does not handle connection errors properly #3511

Open
1 task done
oskarlh opened this issue Mar 27, 2025 · 0 comments
Open
1 task done

Comments

@oskarlh
Copy link

oskarlh commented Mar 27, 2025

Check existing issues

Viem Version

2.24.1

Current Behavior

When

  • you use a PublicClient
  • with the webSocket transport
  • and call watchBlocks with the emitOnBegin option,
  • and you do not have an Internet connection
    The script crashes with an error logged to console

Expected Behavior

When

  • you use a PublicClient
  • with the webSocket transport
  • and call watchBlocks with the emitOnBegin option
  • and you do not have an Internet connection
    The onError handler is called

Steps To Reproduce

  • Add something to keep the script alive (like a setInterval)
  • Disable your Internet connection.
  • Create a PublicClient
  • with the webSocket transport,
  • call watchBlocks with the emitOnBegin option
  • Observe that the script stops, with errors logged to stdout

Link to Minimal Reproducible Example

https://github.com/oskarlh/viem-bug

Anything else?

No response

@oskarlh oskarlh changed the title WS watchBlocks with emitOnBegin: true does not handle connection errors properly WebSocket PublicClient watchBlocks with emitOnBegin: true does not handle connection errors properly Mar 27, 2025
@oskarlh oskarlh changed the title WebSocket PublicClient watchBlocks with emitOnBegin: true does not handle connection errors properly WebSocket watchBlocks with emitOnBegin: true does not handle connection errors properly Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant