Post HTTP parser error callbacks
Issue
HTTP parser errors were still reported too close to the transport read stack. Even after storing callback failures until HttpCodecFilter::dispatch() regained control, handleParserError() invoked message_callbacks_->onError() synchronously.
That callback can close MCP connections, destroy transports, and tear down filters. Running it directly from the dispatch/read path risks destroying objects while the current stack still depends on them.
How to reproduce
- Build the SDK with HTTP transport enabled.
- Create an HTTP path using
HttpCodecFilter with message callbacks installed.
- Trigger a parser error from input processing. Examples:
or
an oversized/null body callback that records a pending parser error
- In the message error callback, close the MCP connection or destroy the owning transport/session.
Before the fix, handleParserError() called the error callback immediately. That allowed teardown to run during the same read/dispatch call chain, creating a reentrancy and lifetime hazard.
Expected fixed behavior
handleParserError() now posts the message error callback to the dispatcher.
The parser state is moved to the parse-error state immediately, but user callback execution happens in a later dispatcher turn. This lets the HTTP parser, filter dispatch, and transport read stack unwind before MCP disconnect and destruction logic runs.
Regression check
A regression test should trigger an HTTP parser error and verify:
handleParserError() does not invoke onError() inline;
- the callback runs only after the dispatcher processes posted work;
- closing the connection from
onError() does not destroy the active filter/transport while dispatch() is still on the stack.
Post HTTP parser error callbacks
Issue
HTTP parser errors were still reported too close to the transport read stack. Even after storing callback failures until
HttpCodecFilter::dispatch()regained control,handleParserError()invokedmessage_callbacks_->onError()synchronously.That callback can close MCP connections, destroy transports, and tear down filters. Running it directly from the dispatch/read path risks destroying objects while the current stack still depends on them.
How to reproduce
HttpCodecFilterwith message callbacks installed.or
Before the fix,
handleParserError()called the error callback immediately. That allowed teardown to run during the same read/dispatch call chain, creating a reentrancy and lifetime hazard.Expected fixed behavior
handleParserError()now posts the message error callback to the dispatcher.The parser state is moved to the parse-error state immediately, but user callback execution happens in a later dispatcher turn. This lets the HTTP parser, filter dispatch, and transport read stack unwind before MCP disconnect and destruction logic runs.
Regression check
A regression test should trigger an HTTP parser error and verify:
handleParserError()does not invokeonError()inline;onError()does not destroy the active filter/transport whiledispatch()is still on the stack.