Skip to content

Commit

Permalink
tweak: Recover from any panics in trace streams.
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler-smith committed Nov 6, 2023
1 parent c1d54c9 commit 6a123e6
Showing 1 changed file with 16 additions and 0 deletions.
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

0 comments on commit 6a123e6

Please sign in to comment.