Skip to content

rpc fix streaming trace methods returning result:null in case of error#21922

Merged
AskAlexSharov merged 4 commits into
mainfrom
lupin012/fix_trace_result_null_on_error
Jun 21, 2026
Merged

rpc fix streaming trace methods returning result:null in case of error#21922
AskAlexSharov merged 4 commits into
mainfrom
lupin012/fix_trace_result_null_on_error

Conversation

@lupin012

@lupin012 lupin012 commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Remove stream.WriteNil() from early error paths in traceBlock, TraceTransaction, and traceCallMany. With the resultFieldStream wrapper introduced in #19267, writing nil to the stream before returning an error marks rs.written=true and forces "result":null into the response alongside the error — violating JSON-RPC 2.0 section 5 (result MUST NOT exist when error is present).

Add TestTraceErrorPathsWriteNoStream to verify the stream buffer stays empty on early error returns.

To fix hive rpc-compact:

  • debug_traceBlockByHash/trace-genesis
  • debug_traceBlockByNumber/trace-genesis

…ide error

Remove stream.WriteNil() from early error paths in traceBlock,
TraceTransaction, and traceCallMany. With the resultFieldStream
wrapper introduced in #19267, writing nil to the stream before
returning an error marks rs.written=true and forces "result":null
into the response alongside the error — violating JSON-RPC 2.0
section 5 (result MUST NOT exist when error is present).

Add TestTraceErrorPathsWriteNoStream to verify the stream buffer
stays empty on early error returns.
@lupin012 lupin012 requested a review from AskAlexSharov June 20, 2026 20:15
@lupin012 lupin012 marked this pull request as ready for review June 21, 2026 09:14
@AskAlexSharov AskAlexSharov enabled auto-merge June 21, 2026 11:18
@AskAlexSharov AskAlexSharov added this pull request to the merge queue Jun 21, 2026
Merged via the queue into main with commit 6bee208 Jun 21, 2026
91 checks passed
@AskAlexSharov AskAlexSharov deleted the lupin012/fix_trace_result_null_on_error branch June 21, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants