Skip to content
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

tweak: Recover from any panics in trace streams. #149

Merged
merged 1 commit into from
Nov 6, 2023
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
16 changes: 16 additions & 0 deletions eth/filters/trace_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ func (api *FilterAPI) NewPendingTransactionsWithTrace(ctx context.Context, trace
metricsPendingTxsNew.Inc(1)
defer metricsPendingTxsEnd.Inc(1)

// Recover from any panics. Should be the last deferred call so it runs
// first.
defer func() {
if r := recover(); r != nil {
log.Error("pending_txs_stream panic:", r)
}
}()

for {
select {
case txs := <-txs:
Expand Down Expand Up @@ -175,6 +183,14 @@ func (api *FilterAPI) NewFullBlocksWithTrace(ctx context.Context, tracerOptsJSON
metricsBlocksNew.Inc(1)
defer metricsBlocksEnd.Inc(1)

// Recover from any panics. Should be the last deferred call so it runs
// first.
defer func() {
if r := recover(); r != nil {
log.Error("block_stream panic:", r)
}
}()

var hashes []common.Hash
for {
select {
Expand Down