Skip to content

fix: reset SSE event type and id buffers after dispatch - #1094

Open
ez-lbz wants to merge 1 commit into
modelcontextprotocol:mainfrom
ez-lbz:reset-sse-event-type-after-dispatch
Open

fix: reset SSE event type and id buffers after dispatch#1094
ez-lbz wants to merge 1 commit into
modelcontextprotocol:mainfrom
ez-lbz:reset-sse-event-type-after-dispatch

Conversation

@ez-lbz

@ez-lbz ez-lbz commented Aug 16, 2026

Copy link
Copy Markdown

Per the WHATWG SSE spec (§9.2.6), both the data buffer and the event type buffer must be reset when an event is dispatched. The SseLineSubscriber only reset the data buffer, so a prior named event (e.g. event: ping) made every subsequent bare data: JSON-RPC message carry the stale event type. The client's isMessageEvent check then silently dropped those messages, leaving pending requests hanging.

This change resets the event type and id buffers alongside the data buffer when an event is dispatched, and in hookOnComplete when a pending event is emitted.

Tests feed the subscriber a named event followed by a bare data event and assert the second event has no stale type or id.

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.

1 participant