Repository navigation
fix(events): send --metadata on events/stream and every request a subscription makes - #3063
Merged
Merged
Conversation
…scription makes (#3062) events/stream used --metadata only for the events/list lookup: eventsStreamOutcome took no metadata, and EventSubscriptionsState had nowhere to keep it, so the stream request and every reconnect went without it. EventSubscribeOptions now takes metadata; the engine keeps it on the entry (off the snapshot, like the webhook secret), carries it across a resume that omits it, and passes it on every poll, stream, reconnect, webhook subscribe/refresh and unsubscribe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
There was a problem hiding this comment.
🟡 Changes recommended
Automatic re-listing omits retained subscription metadata, which can select the wrong event types or fail and incorrectly disable resubscription; metadata forwarding and termination-path test coverage are still needed.
1 open issue
What changed in this PR
This PR addresses #3062 by forwarding CLI --metadata into the shared event subscription engine, preserving it across reconnects and subscription lifecycle requests.
Changes:
- Adds subscription metadata storage, retaining it on resume unless replaced.
- Forwards metadata to stream, poll, webhook subscribe, refresh, and unsubscribe requests.
- Adds engine and CLI regression tests for metadata propagation.
| File | Description |
|---|---|
core/mcp/state/eventSubscriptionsState.ts |
Stores metadata and forwards it to subscription requests. |
core/cli/handlers/run-method.ts |
Passes CLI metadata to the stream handler. |
core/cli/handlers/events.ts |
Carries stream metadata into subscription options. |
clients/web/src/test/core/mcp/state/eventSubscriptionsState.webhook.test.ts |
Tests metadata across the webhook lifecycle. |
clients/web/src/test/core/mcp/state/eventSubscriptionsState.test.ts |
Tests metadata on streams, reconnects, polls, and resumes. |
clients/cli/__tests__/events.test.ts |
Tests metadata forwarding through runMethod. |
Review effort: Balanced
…tion (#3062) Addresses review on #3063. After a contract-changing termination the engine re-lists the event types to decide whether to offer a resubscribe, and that listAllEvents call went without the subscription's metadata. The default re-list now sends it, and an injected relist receives it as its argument; the web and TUI hosts, which refresh a shared list, keep ignoring it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
Member
Author
|
Round 1 addressed in bc6490c:
|
Member
Author
|
Copilot review loop closed after round 2: the round was clean (0 inline comments, nothing suppressed, approval recommended, round 1's finding marked resolved), so no further round was requested. |
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.

Closes #3062
events/streamdropped--metadatafrom the stream request and from every reconnect. Copilot found it while reviewing the 2.17.0 milestone merge (#3061). The fix goes onv2/mainand reaches the merge by re-merging, per thereleaseskill, 2c.Cause
run-methodpassedargs.metadataonly toresolveEventType, theevents/listlookup.eventsStreamOutcometook onlyargumentsandcursor.EventSubscriptionsStatehad nometadatainEventSubscribeOptions, so its runners calledclient.streamEvents(andpollEvents,subscribeEvents,unsubscribeEvents) without any, even though every one of those client methods accepts it.Change
EventSubscribeOptions.metadata. The engine keeps it on the registry entry, off the snapshot the UI reads (the same treatment as the webhook secret). It sends it on every request the subscription makes: the first poll or stream, every reconnect, webhook subscribe and refresh, and the webhook unsubscribe. A resume that omits it keeps the previous run's metadata, and new metadata replaces it.eventsStreamOutcometakesmetadata, andrun-methodpasses--metadatato it.metadatakey.Verified
New tests. 4 in the engine (push stream plus reconnect, every poll, none when none is given, resume keeps or replaces) and 1 in webhook (subscribe, refresh, unsubscribe). 1 CLI test through
runMethodagainst the Events fixture, with a spy onstreamEvents. All 5 fail without thecore/change and pass with it.End to end, with
mcpdo @evp events/stream incident.created --metadata com.example/trace=abcthrough a proxy that logsparams._meta, forcing a reconnect withinject_event_failure preset:=stall_stream:events/listevents/stream, first and reconnect8f79314d, the 2.17.0 merge)"com.example/trace":"abc""com.example/trace":"abc""com.example/trace":"abc"on bothnpm run local:gate: green (4m56s). Web 10,987 tests, cli 1,230, with coverage unchanged.🤖 Generated with Claude Code