Skip to content

Drop a buffered notification that cannot be generated - #630

Merged
koic merged 1 commit into
modelcontextprotocol:mainfrom
koic:drop_a_buffered_notification_that_cannot_be_generated
Oct 24, 2026
Merged

koic merged 1 commit into
modelcontextprotocol:mainfrom
koic:drop_a_buffered_notification_that_cannot_be_generated

Conversation

@koic

@koic koic commented Oct 23, 2026

Copy link
Copy Markdown
Member

Motivation and Context

On the 2026-07-28 path the Streamable HTTP transport buffers the notifications a handler emits during a request and writes them as SSE frames ahead of the response once the handler returns. A notification holding a string that is not valid UTF-8, such as log data a tool passed to notify_log_message, raised JSON::GeneratorError while the frames were written, and the whole exchange was answered with 500, losing the response the handler had produced.

The transport now generates each notification when it is buffered. One that cannot be generated is reported to the exception reporter and dropped as non-delivery (false), as the buffer already does past its cap, and the other notifications and the response are written as before.

How Has This Been Tested?

test/mcp/server/transports/streamable_http_transport_test.rb. Against the previous library the new test answers 500.

Breaking Changes

None.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

atesgoral
atesgoral previously approved these changes Oct 23, 2026
## Motivation and Context

On the 2026-07-28 path the Streamable HTTP transport buffers the notifications a handler emits during a request
and writes them as SSE frames ahead of the response once the handler returns. A notification holding a string
that is not valid UTF-8, such as log data a tool passed to `notify_log_message`, raised `JSON::GeneratorError`
while the frames were written, and the whole exchange was answered with 500, losing the response the handler
had produced.

The transport now generates each notification when it is buffered. One that cannot be generated is reported to
the exception reporter and dropped as non-delivery (`false`), as the buffer already does past its cap, and
the other notifications and the response are written as before.

## How Has This Been Tested?

`test/mcp/server/transports/streamable_http_transport_test.rb`. Against the previous library the new test
answers 500.

## Breaking Changes

None.
@koic
koic force-pushed the drop_a_buffered_notification_that_cannot_be_generated branch from 589234f to 89772bf Compare October 24, 2026 17:33
@koic
koic merged commit ec6501b into modelcontextprotocol:main Oct 24, 2026
11 checks passed
@koic
koic deleted the drop_a_buffered_notification_that_cannot_be_generated branch October 24, 2026 17:34
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