Skip to content

Commit c37b1f4

Browse files
barnabasbusaclaude
andcommitted
Fix nil pointer panic in beacon event stream on context cancellation
When subscribeStream returns nil (e.g. context canceled), startStream now returns early instead of falling through to the select loop where it would dereference nil basicStream fields. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4afed9e commit c37b1f4

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

clients/consensus/rpc/beaconstream.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,10 @@ func (bs *BeaconStream) startStream() {
7676
// Subscribe to basic events (block, head, finalized_checkpoint)
7777
basicEvents := bs.events & (StreamBlockEvent | StreamHeadEvent | StreamFinalizedEvent)
7878
basicStream := bs.subscribeStream(bs.client.endpoint, basicEvents)
79-
if basicStream != nil {
80-
defer basicStream.Close()
79+
if basicStream == nil {
80+
return
8181
}
82+
defer basicStream.Close()
8283

8384
// Subscribe to advanced events (execution_payload_available, execution_payload_bid)
8485
// These are in a separate stream because clients may not support them yet,

0 commit comments

Comments
 (0)