Fix: Viem sends random undefined blocks#575
Conversation
|
|
||
| private onNewBlock(block: LatestBlock) { | ||
| private onNewBlock(block: LatestBlock | undefined) { | ||
| if (!block) { |
There was a problem hiding this comment.
so weird this can happen.. I see they are somewhat dangerously-widening casting to any here: https://github.com/wevm/viem/blob/main/src/actions/public/watchBlocks.ts#L172
looking through the docs and implementation for Viems watchBlocks there is also emitMissed
https://viem.sh/docs/actions/public/watchBlocks.html#emitmissed-optional
https://github.com/wevm/viem/blob/main/src/actions/public/watchBlocks.ts#L162
looking at the implementation it detects if the "latest" block number is not +1 from the last, and will send the missing blocks in the interval. this might be useful for us. wdyt? can be a another PR
There was a problem hiding this comment.
Could be interesting but would need to be handled with caution as the blocks as used as a clock as well so we wouldn't want to trigger say the transaction monitor in rapid fire.
In fact, I think we don't otherwise need to see every block — but we should make sure. Can we enqueue an issue for this (= make sure it's okay if we miss block + document).
d9ca14c to
0563ec5
Compare
0cfc909 to
357ffc8
Compare
0563ec5 to
f8961b8
Compare
357ffc8 to
7776719
Compare
f8961b8 to
4b1dec2
Compare
7776719 to
e914fb7
Compare
4b1dec2 to
269498c
Compare
e914fb7 to
8372d4b
Compare
a5a0a16 to
7bd96c6
Compare
8238eea to
cd47176
Compare
7bd96c6 to
1952e64
Compare
cd47176 to
0f7df60
Compare
1952e64 to
ff6ba03
Compare
0f7df60 to
dfdc6c0
Compare
ff6ba03 to
9b6be7f
Compare
dfdc6c0 to
0f799ad
Compare
9b6be7f to
52f3721
Compare
0f799ad to
f362034
Compare
52f3721 to
cf6a8e8
Compare
f362034 to
d817440
Compare
cf6a8e8 to
d388440
Compare
d817440 to
b121ba5
Compare
d388440 to
3e362df
Compare
b121ba5 to
650af43
Compare
3e362df to
48d79d7
Compare
650af43 to
641e505
Compare
48d79d7 to
d3a8679
Compare
641e505 to
b61eeba
Compare
b61eeba to
db10c52
Compare

Description
Viem sends random undefined blocks during network problems, which causes unexpected behavior
Toggle Checklist
Checklist
Basics
norswap/build-system-caching).Reminder: PR review guidelines
Correctness
testnet, mainnet, standalone wallet, ...).
< INDICATE BROWSER, DEMO APP & OTHER ENV DETAILS USED FOR TESTING HERE >
< INDICATE TESTED SCENARIOS (USER INTERFACE INTERACTION, CODE FLOWS) HERE >
and have updated the code & comments accordingly.
Architecture & Documentation
(2) commenting these boundaries correctly, (3) adding inline comments for context when needed.
comments.
in a Markdown document.
packages/coreandpackages/react), see here for more info.