-
Notifications
You must be signed in to change notification settings - Fork 19
catch panic from decodeLogFunc #215
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
Conversation
WalkthroughA panic recovery mechanism was introduced in the goroutine responsible for log decoding within the Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant DecodeLogs
participant Goroutine
participant Logger
Caller->>DecodeLogs: Call DecodeLogs(logs, chainId)
loop For each log
DecodeLogs->>Goroutine: Launch decodeLogFunc in goroutine
alt Panic occurs in Goroutine
Goroutine->>Logger: Log error with chainId, logs, and panic error
else No panic
Goroutine->>Goroutine: Process log normally
end
end
DecodeLogs-->>Caller: Return results
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
🧹 Nitpick comments (1)
internal/common/log.go (1)
88-131
: Consider adding bounds checking for concurrent slice access.While the current implementation uses proper synchronization with WaitGroup, there's a potential race condition concern. The
decodedLogs
slice is accessed concurrently by multiple goroutines without explicit bounds checking.Consider adding bounds validation to make the code more robust:
go func(idx int, eventLog Log, mut *sync.Mutex) { + if idx >= len(decodedLogs) { + log.Error().Int("index", idx).Int("length", len(decodedLogs)).Msg("Index out of bounds in DecodeLogs") + wg.Done() + return + } defer func() { if err := recover(); err != nil { log.Error().This prevents potential out-of-bounds access in edge cases where the slice might be modified concurrently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set the log to decodedLogs slice when the panic is caught
Summary by CodeRabbit