Skip to content

fix(notifications): handle BlockNotFoundError#203

Merged
shoom3301 merged 2 commits intomainfrom
fix/block-not-found
Mar 2, 2026
Merged

fix(notifications): handle BlockNotFoundError#203
shoom3301 merged 2 commits intomainfrom
fix/block-not-found

Conversation

@shoom3301
Copy link
Contributor

@shoom3301 shoom3301 commented Feb 26, 2026

There is constant crash-looping with BlockNotFoundError error, which happens only on BSC chain (more likely related to reorgs).
We should not crash in that case and just skip the block.

image

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling for trade notification processing to gracefully manage block lookup failures, preventing processing interruption and enhancing system resilience with better logging and error recovery.

@shoom3301 shoom3301 requested a review from a team February 26, 2026 12:45
@shoom3301 shoom3301 self-assigned this Feb 26, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 59d1746 and 358cf7d.

⛔ Files ignored due to path filters (1)
  • libs/repositories/src/gen/cow/cow-api-types.ts is excluded by !**/gen/**
📒 Files selected for processing (1)
  • apps/notification-producer/src/producers/trade/TradeNotificationProducer.ts

📝 Walkthrough

Walkthrough

The TradeNotificationProducer adds error handling for BlockNotFoundError when retrieving block data. A try/catch block now wraps the getBlock call, logging a warning and breaking batch processing when this specific error occurs, while rethrowing other errors.

Changes

Cohort / File(s) Summary
Error Handling Enhancement
apps/notification-producer/src/producers/trade/TradeNotificationProducer.ts
Added BlockNotFoundError exception handling with try/catch around block retrieval; logs warning and breaks batch processing on BlockNotFoundError while rethrowing other exceptions. Imported BlockNotFoundError type from viem.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A block went missing, oh my dear,
But now we catch it without fear,
A warning logged, a graceful break,
This rabbit's code makes no mistake! 🐇

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately describes the main change: adding error handling for BlockNotFoundError in the notification producer.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/block-not-found

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@shoom3301 shoom3301 enabled auto-merge (squash) March 2, 2026 12:26
@shoom3301 shoom3301 merged commit a58ca33 into main Mar 2, 2026
9 checks passed
@shoom3301 shoom3301 deleted the fix/block-not-found branch March 2, 2026 12:28
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

Successfully merging this pull request may close these issues.

3 participants