fix: resolve transaction monitoring race condition causing false failures#1433
Open
fix: resolve transaction monitoring race condition causing false failures#1433
Conversation
Fixed multiple bugs in MonitorTransaction that caused false tx failure reports: 1. Race condition: Previously checked error count prematurely (len == 2) and could exit before API polling discovered the transaction. Now we wait for both goroutines to complete before deciding success/failure. 2. Channel logic bug: The condition `if resultChan == nil && errChan == nil` could never be true because channels don't become nil when closed in Go. Now using boolean flags to track channel closure. 3. Resource leak: Fixed defer inside loop that accumulated closes. Now closing response body immediately after reading. Fixes #1414 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MonitorTransactionthat caused false "tx failed" reportsContext
Fixes #1414 ("roller reports tx failure, while it actually passed")
Users were seeing "failed to register sequencer" errors even though transactions succeeded on-chain. The root cause was a race condition in the transaction monitoring logic.
Root Cause Analysis
Bug 1: Premature Error Exit
If WebSocket monitoring failed immediately (e.g., due to wrong URL scheme), we'd exit before API polling had a chance to find the transaction.
Bug 2: Incorrect Channel Closure Check
Bug 3: Resource Leak
Solution
Changes
utils/tx/tx.go: FixedMonitorTransactionfunctionTest plan
🤖 Generated with Claude Code