Skip to content

Reduce absolute time dependencies in tests#1649

Open
PranavSenthilnathan wants to merge 2 commits into
modelcontextprotocol:mainfrom
PranavSenthilnathan:fix-test-race
Open

Reduce absolute time dependencies in tests#1649
PranavSenthilnathan wants to merge 2 commits into
modelcontextprotocol:mainfrom
PranavSenthilnathan:fix-test-race

Conversation

@PranavSenthilnathan

@PranavSenthilnathan PranavSenthilnathan commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

The test helper InMemoryTaskStore mutates TaskEntry fields without synchronization. FailTask/CompleteTask/CancelTask set Status before their payload field (Error/Result), so a concurrent reader in GetTask could observe Status == Failed with Error == null and throw 'Nullable object must have a value', surfacing to the client as a McpProtocolException instead of the expected McpException.

Serialize all reads and writes under a lock on the backing dictionary, and reorder mutations so Status is assigned last.

In addition, use explicit signaling in tests instead of arbitrary wait times.

Fixes #1648
Fixes #1661

The test helper InMemoryTaskStore mutates TaskEntry fields without
synchronization. FailTask/CompleteTask/CancelTask set Status before
their payload field (Error/Result), so a concurrent reader in GetTask
could observe Status == Failed with Error == null and throw
'Nullable object must have a value', surfacing to the client as a
McpProtocolException instead of the expected McpException.

Serialize all reads and writes under a lock on the backing dictionary,
and reorder mutations so Status is assigned last.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
halter73
halter73 previously approved these changes Jun 12, 2026
@PranavSenthilnathan PranavSenthilnathan changed the title Fix race in test InMemoryTaskStore (#1648) Reduce absolute time dependencies in tests Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants