Skip to content

chore: log panic line in ticker error#2881

Merged
gartnera merged 1 commit intodevelopfrom
ticker-log-panic-line
Sep 16, 2024
Merged

chore: log panic line in ticker error#2881
gartnera merged 1 commit intodevelopfrom
ticker-log-panic-line

Conversation

@gartnera
Copy link
Contributor

@gartnera gartnera commented Sep 14, 2024

We're seeing a panic on mainnet which causes an inbound processing halt.

{"level":"error","chain":56,"module":"inbound","error":"panic during ticker run: runtime error: invalid memory address or nil pointer dereference","worker.name":"WatchInbound","time":"2024-09-14T01:34:02Z","message":"Background task failed"}

Add ensure the we log the full path to any panics for debugging. Test coverage proves that we select the correct line for the message. We already built and deployed a binary manually on mainnet which gives us a useful result:

{"level":"error","chain":56,"module":"inbound","error":"panic during ticker run: runtime error: invalid memory address or nil pointer dereference at /go/src/github.com/zeta-chain/node/zetaclient/chains/evm/observer/observer.go:340 +0x34","worker.name":"WatchInbound","time":"2024-09-14T01:33:40Z","message":"Background task failed"}

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced error handling to capture and report stack traces during panic scenarios in the ticker functionality.
  • Tests

    • Introduced a new test case to validate panic handling, ensuring accurate error reporting for nil pointer dereferences.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 14, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Walkthrough

The changes involve enhancing error handling in the Run method of the Ticker struct by capturing stack traces during panics and providing contextual error messages. Additionally, a new test case is introduced to verify the handling of panic scenarios, specifically addressing nil pointer dereferences. This update aims to improve debugging capabilities and ensure the robustness of the ticker's error handling.

Changes

File Change Summary
pkg/ticker/ticker.go Enhanced error handling in the Run method to capture stack traces during panics and improve error messages.
pkg/ticker/ticker_test.go Added a test case in TestTicker to validate panic handling, specifically for nil pointer dereferences.

Sequence Diagram(s)

sequenceDiagram
    participant T as Ticker
    participant R as Run Method
    participant E as Error Handling
    participant S as Stack Trace

    T->>R: Start Run
    R->>E: Execute code
    alt Panic Occurs
        R->>S: Capture stack trace
        S->>E: Process stack trace
        E-->>R: Return error with context
    end
    R-->>T: Complete Run
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link

codecov bot commented Sep 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.90%. Comparing base (75a4189) to head (77082bb).
Report is 6 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2881      +/-   ##
===========================================
- Coverage    66.94%   66.90%   -0.05%     
===========================================
  Files          373      377       +4     
  Lines        21032    21087      +55     
===========================================
+ Hits         14080    14108      +28     
- Misses        6288     6315      +27     
  Partials       664      664              
Files with missing lines Coverage Δ
pkg/ticker/ticker.go 86.95% <100.00%> (+1.59%) ⬆️

... and 14 files with indirect coverage changes

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9988584 and 9321074.

Files selected for processing (2)
  • pkg/ticker/ticker.go (2 hunks)
  • pkg/ticker/ticker_test.go (1 hunks)
Additional context used
Path-based instructions (2)
pkg/ticker/ticker.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

pkg/ticker/ticker_test.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

Additional comments not posted (3)
pkg/ticker/ticker.go (1)

32-33: LGTM!

The imports are correctly placed and necessary for the enhanced error handling implementation.

pkg/ticker/ticker_test.go (2)

150-152: LGTM!

The test case correctly verifies that the ticker captures the panic message and the line number where the panic occurred. This enhances the error handling and debugging capabilities.


154-172: LGTM!

The test case correctly verifies that the ticker captures the nil pointer dereference panic and the line number where the panic occurred. This ensures that the ticker can gracefully handle and report such panics, improving the robustness of the error handling.

@gartnera gartnera force-pushed the ticker-log-panic-line branch from 9321074 to 77082bb Compare September 14, 2024 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog Skip changelog CI check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants