Skip to content

Reduce absolute time dependencies in tests#1649

Merged
PranavSenthilnathan merged 2 commits into
modelcontextprotocol:mainfrom
PranavSenthilnathan:fix-test-race
Jun 24, 2026
Merged

Reduce absolute time dependencies in tests#1649
PranavSenthilnathan merged 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
@PranavSenthilnathan PranavSenthilnathan merged commit e7b450e into modelcontextprotocol:main Jun 24, 2026
10 checks passed
@PranavSenthilnathan PranavSenthilnathan deleted the fix-test-race branch June 24, 2026 17:20
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