From 32030ef100a5c2f94899ccbef59bfbe75c643d49 Mon Sep 17 00:00:00 2001 From: Janez Podhostnik Date: Mon, 10 Aug 2026 14:36:38 +0200 Subject: [PATCH] Retry on Unavailable gRPC errors, reduce result channel buffer Retry when the connection drops (codes.Unavailable); gRPC reconnects on the next attempt so these errors are transient. Reduce the script result channel buffer from 10000 to 500 to apply backpressure to producers earlier and bound memory usage. --- client/interceptors/uci_retry.go | 6 ++++++ scanner/output_handler.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/client/interceptors/uci_retry.go b/client/interceptors/uci_retry.go index ace9747..ceefa9e 100644 --- a/client/interceptors/uci_retry.go +++ b/client/interceptors/uci_retry.go @@ -53,6 +53,12 @@ func RetryUnaryClientInterceptor( return true } + // Retry when the connection drops (e.g. "connection timed out"). + // This is transient: gRPC will reconnect on the next attempt. + if code == codes.Unavailable { + return true + } + if strings.Contains(err.Error(), "please retry for collection in finalized block") { return true } diff --git a/scanner/output_handler.go b/scanner/output_handler.go index 1627a9e..2c85ebc 100644 --- a/scanner/output_handler.go +++ b/scanner/output_handler.go @@ -35,7 +35,7 @@ func NewScriptResultProcessor( handler ScriptResultHandler, ) *ScriptResultProcessor { r := &ScriptResultProcessor{ - resultsChan: make(chan ProcessedAddressBatch, 10000), + resultsChan: make(chan ProcessedAddressBatch, 500), handler: handler, log: logger.With().Str("component", "script_result_processor").Logger(), }