Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/txm/lib/BlockMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ export class BlockMonitor {
})
}

private onNewBlock(block: LatestBlock) {
private onNewBlock(block: LatestBlock | undefined) {
if (!block) {
Copy link
Contributor

@aodhgan aodhgan Apr 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Logger.instance.error(LogTag.TXM, "Received undefined block")
return
}

if (this.blockTimeout) clearTimeout(this.blockTimeout)
eventBus.emit(Topics.NewBlock, block)

Expand Down
Loading