Skip to content

Fix thread unloading after disconnect during MCP startup - #50380

Merged
copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/4ad912a82177266316042d806f5faa1713a48fa4
Oct 2, 2026
Merged

copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/4ad912a82177266316042d806f5faa1713a48fa4

Conversation

@copyberry

@copyberry copyberry Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Fix thread unloading after disconnect during MCP startup

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.

## 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
@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/4ad912a82177266316042d806f5faa1713a48fa4 branch from b588f6d to 1ab8c6e Compare October 2, 2026 17:40
@copyberry
copyberry Bot merged commit 1ab8c6e into main Oct 2, 2026
1 check failed
@copyberry
copyberry Bot deleted the copyberry/codex-internal-to-codex-oss/4ad912a82177266316042d806f5faa1713a48fa4 branch October 2, 2026 17:40
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@github-actions github-actions Bot locked and limited conversation to collaborators Oct 2, 2026
@YoyoSika
YoyoSika deployed to issue-triage October 2, 2026 17:46 — with GitHub Actions Active
@YoyoSika
YoyoSika deployed to issue-triage October 2, 2026 17:46 — with GitHub Actions Active
@YoyoSika
YoyoSika deployed to issue-triage October 2, 2026 17:46 — with GitHub Actions Active
@GiorgiKemo
GiorgiKemo deployed to issue-triage October 2, 2026 17:50 — with GitHub Actions Active
@GiorgiKemo
GiorgiKemo deployed to issue-triage October 2, 2026 17:50 — with GitHub Actions Active
@GiorgiKemo
GiorgiKemo deployed to issue-triage October 2, 2026 17:50 — with GitHub Actions Active
@GiorgiKemo
GiorgiKemo deployed to issue-triage October 2, 2026 17:51 — with GitHub Actions Active

This branch was successfully deployed

1 active deployment
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants