fix: surface per-block execution timeouts instead of silently swallowing them#790
Merged
sduchesneau merged 2 commits intoMay 28, 2026
Conversation
…ing them When a WASM host function (e.g. eth_call) panics in wasmtime because the per-block execution context's deadline has fired, the panic propagates up to Pipeline.execute's deferred recover, which re-panics with "unknown error: %s" (chain broken) up to executeModules's deferred recover, which calls recoverExecutionPanic. recoverExecutionPanic had two bugs that combined to silently drop the offending block: 1. The DeadlineExceeded handler was dead code: the catch-all `if ctx.Err() != nil || errors.Is(recoveredErr, context.Canceled)` above it matched DeadlineExceeded too, so the deadline-specific branch below was never reached. The function would return `executionError` (typically nil), making executeModules return nil and the pipeline move on to the next block as if nothing happened. 2. Pipeline.execute's re-panic used `%s` instead of `%w` when wrapping the recovered error, severing the wrap chain so callers couldn't `errors.Is(err, context.DeadlineExceeded)` even when the swallow condition was avoided. Fix: - Check `errors.Is(ctx.Err(), context.DeadlineExceeded)` first so the intended `CodeDeadlineExceeded` connect error is returned. The catch-all for Canceled remains below. - Wrap the recovered error with `%w` on re-panic so the deadline information survives all the way to the gRPC error mapper. Bug introduced in commit 5b3f59b (2025-10-21, "Improved panic handling and make clearer the intent when throwing errors in the WASM handlers"), present in v1.17.0 onward. Affects wasmtime (default runtime for Rust-built spkgs); wazero is unaffected because it converts host panics to error returns at f.Call(), bypassing the recover path. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Five focused unit tests covering each branch of recoverExecutionPanic.
The deadline-exceeded test asserts:
- result is non-nil (catches the silent-swallow regression directly)
- result is a connect.Error with CodeDeadlineExceeded
- the original context.DeadlineExceeded survives the wrap chain so
callers can errors.Is() on it
- the block ref is in the message
Verified: this test fails on the pre-fix code with the exact assertion
"deadline-exceeded panic must not be silently swallowed", and passes
with the fix.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
Since 5b3f59b2 if block execution times out (like with non-deterministic
eth_callcall loop), the substreams engine quietly swallows that timeout error and skips the block as if it doesn't have any output.This PR should fix it.
Symptom
Running in development mode against tier1 node with
--substreams-block-execution-timeout=90s:retrying RPCCall on non-deterministic RPC call errorfor ~90s on a stucketh_call.INFO (rpc-cache) stopping rpc calls here, context is canceledfires (rpccalls.go:467) — proving the per-block ctx hit its deadline.substreams request stats ... "error": "". The client seesCompleted successfully. Egress stats showProcessed Blocks: 1, Received Blocks: 2— one block silently dropped.Root cause
Two combined bugs in
pipeline/process_block.go:1. Dead code in
recoverExecutionPanic:The catch-all
ctx.Err() != nilmatchesDeadlineExceeded, so the deadline-specific branch never fires. Function returnsexecutionError(typically nil) →executeModulesreturns nil → block silently skipped.2. Broken error chain in
Pipeline.execute's re-panic:Uses
%sinstead of%w, severing the wrap chain. Even if the dead code were fixed, downstream callers couldn'terrors.Is(err, context.DeadlineExceeded)on the result.Path through the code (for wasmtime)
rpccalls.go:476returns"timeout while doing eth_call ... cause: %w"wrappingcontext.DeadlineExceeded.wasm/wasmtime/instance.go:49panic(fmt.Errorf("running wasm extension ...: %w", err)).entrypoint.Call()(no recover inwasm/wasmtime/module.go).wasmCall→mapexec.run→RunModuletoPipeline.execute's deferred recover.ErrWasmDeterministicExec/ErrFoundationalStoreCanceled→ re-panic with broken%swrap.executeModules's deferred recover →recoverExecutionPanic(ctx, nil, ...).ctx.Err() != nil(DeadlineExceeded) → returnsnil.block.Number > stopBlockNum,handleStepNewreturnsio.EOF→ stream "succeeds".Wazero is unaffected: it converts host-function panics to error returns at
f.Call(), so the recover path isn't entered.Fix
recoverExecutionPanic: checkerrors.Is(ctx.Err(), context.DeadlineExceeded)before the catch-all so deadline-exceeded gets the intendedCodeDeadlineExceededconnect error.Pipeline.execute's re-panic: wrap with%wso the chain is preserved for any callers that inspect it.Bug introduced
Commit 5b3f59b (2025-10-21, "Improved panic handling and make clearer the intent when throwing errors in the WASM handlers") added
ctx.Err() != nil ||to a previously-correct condition. Present in v1.17.0 and every release since.Test plan
go vet ./pipeline/...cleango test -short ./pipeline/...passeseth_callon a non-deterministic error (e.g. RethStackUnderflow) with--substreams-block-execution-timeout=90s. Before this PR: client seesCompleted successfullywithProcessed: N-1 / Received: N. After: client seesDeadlineExceededgRPC error withexecution timed out at block ....🤖 Generated with Claude Code