fix(beacon-node): cast emitter at the failing emit site to fix tsgo overload - #9491
Merged
nflaig merged 1 commit intoJun 9, 2026
Conversation
…verload The previous restructure (ChainSafe#9488) removed the let !+destructuring pattern but tsgo still picks the wrong emit overload for ChainEvent.X at this site when emitter is captured by a sibling closure (the processBlock mock that emits routes.events.EventType.block). Same TS2769 error reproduces: test/unit/sync/unknownBlock.test.ts(1027,20): error TS2769: No overload matches this call. Argument of type 'ChainEvent.unknownEnvelopeBlockRoot' is not assignable to parameter of type 'unique symbol'. Apply an explicit (emitter as ChainEventEmitter) cast at the failing call site to re-anchor the StrictEventEmitter overload. Minimal change; the 5 other emitter.emit(ChainEvent.unknownEnvelopeBlockRoot, ...) sites in the file remain unchanged because they aren't reached through a sibling closure capture. 🤖 Generated with AI assistance
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates a unit test in unknownBlock.test.ts by casting emitter to ChainEventEmitter when emitting ChainEvent.unknownEnvelopeBlockRoot to resolve a TypeScript overload-resolution issue. There are no review comments, and I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
nflaig
merged commit Jun 9, 2026
9b2aa84
into
ChainSafe:te/fix_block_input_sync_metrics_logs
15 of 16 checks passed
2 tasks
nflaig
pushed a commit
that referenced
this pull request
Jun 9, 2026
…emit (#9492) ## Summary The base-branch update brought in #9479's new test ("defers envelope validation until the block is in fork choice when payload input is seeded from the block body") which uses the same `let emitter!: ChainEventEmitter` + destructuring-assignment + sibling closure capture pattern that #9491 already mitigated in the original failing test below. Same `TS2769` fires at the new test's emit site: ``` test/unit/sync/unknownBlock.test.ts(1027,20): error TS2769: No overload matches this call. Argument of type 'ChainEvent.unknownEnvelopeBlockRoot' is not assignable to parameter of type 'unique symbol'. ``` Also, #9479's emit predates this PR's addition of `slot: Slot` to the `ChainEvent.unknownEnvelopeBlockRoot` event signature, so the emit data is missing the required `slot` field after the merge. ## Fix Same minimal cast workaround as #9491 plus the required `slot: 0` field: ```diff - emitter.emit(ChainEvent.unknownEnvelopeBlockRoot, { + // tsgo overload-resolution miss when emit is reached through a closure that captures emitter + // first; cast re-anchors the StrictEventEmitter overload for ChainEvent keys (see #9491). + (emitter as ChainEventEmitter).emit(ChainEvent.unknownEnvelopeBlockRoot, { rootHex: blockRootHex, + slot: 0, peer, source: BlockInputSource.gossip, }); ``` Single-site change. The 5 other `emitter.emit(ChainEvent.unknownEnvelopeBlockRoot, ...)` sites in the file remain unchanged because they aren't reached through a sibling closure capture; the cast at the sibling test's emit (introduced in #9491, currently at line 1126) also remains as-is and continues to typecheck cleanly with the expanded `EventType` union from #9439. ## Test plan - [ ] CI: `Type Checks (24)` passes (no TS2769 on `unknownBlock.test.ts`). - [ ] CI: the new `defers envelope validation until the block is in fork choice when payload input is seeded from the block body` test still passes — emit semantics unchanged. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: lodekeeper <lodekeeper@users.noreply.github.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
Follow-up to #9488 — the restructure removed the
let !+ destructuring pattern but tsgo's overload-resolution miss persists at the same emit site becauseemitteris also captured by a sibling closure (theprocessBlockmock body that emitsroutes.events.EventType.block). SameTS2769error reproduces on the current head:Fix
Cast
emitterat the failing site toChainEventEmitterto re-anchor theStrictEventEmitteroverload forChainEvent.Xkeys. Minimal change — single line cast at line 1023, with a comment explaining why. The 5 otheremitter.emit(ChainEvent.unknownEnvelopeBlockRoot, ...)sites in the file remain untouched because they aren't reached through a sibling closure capture.The previous restructure (now in the base branch) is still worth keeping — it removed an unnecessary indirection — but it wasn't sufficient on its own.
Test plan
Type Checks (24)passes (no TS2769 onunknownBlock.test.ts).🤖 Generated with Claude Code