diff --git a/eth/filters/trace_api.go b/eth/filters/trace_api.go index a3a8a245ea80..59e26cd6bd66 100644 --- a/eth/filters/trace_api.go +++ b/eth/filters/trace_api.go @@ -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: @@ -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 {