Fix thread unloading after disconnect during MCP startup (#50380)

## Why

If required MCP startup outlasts the requesting connection's cleanup, the newly created thread can remain loaded without subscribers because its listener is never started.

## What changed

Start the thread listener even when the requesting connection has already closed, allowing normal idle unloading to clean up the thread while preserving the `ConnectionClosed` result.

## Testing

Add a regression test that disconnects during blocked required MCP startup, then releases startup and verifies a `thread/closed` notification, an empty `thread/loaded/list`, and MCP process exit on Unix.

GitOrigin-RevId: 4ad912a82177266316042d806f5faa1713a48fa4
This commit is contained in:
Yuzhu Shen
2026-10-02 17:40:09 +00:00
committed by copyberry
parent 50b4c5e58c
commit 1ab8c6ef28
3 changed files with 254 additions and 7 deletions
@@ -1911,3 +1911,7 @@ mod message_processor_tracing_tests;
#[cfg(test)]
#[path = "message_processor_gateway_oauth_tests.rs"]
mod gateway_oauth_tests;
#[cfg(test)]
#[path = "message_processor_thread_lifecycle_tests.rs"]
mod thread_lifecycle_tests;