handleAutomaticTaskPolling ignores AbortSignal; cancelled requests poll indefinitely
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- typescript
Research direction
Start in packages/server/src/server/mcp.ts at handleAutomaticTaskPolling and compare its polling loop with the signal check in taskManager.ts around line 856. Confirm that an aborted ctx.mcpReq.signal stops polling with the stated cancellation error, and verify that non-cancelled task polling still reaches completion or failure.
Written by the indexing model from the issue text.
Description
Initial Checks
- Using the latest version of MCP TypeScript SDK
- Searched existing issues
Description
In packages/server/src/server/mcp.ts, handleAutomaticTaskPolling contains a while loop (lines 328-335) that polls a task store until completion. The loop never checks ctx.mcpReq.signal.aborted. If the client cancels the request, the poll loop continues consuming server resources indefinitely.
while (task.status !== 'completed' && task.status !== 'failed' && task.status !== 'cancelled') {
await new Promise(resolve => setTimeout(resolve, pollInterval));
const updatedTask = await ctx.task.store.getTask(taskId);
// ...
}
The taskManager.ts implementation of the same pattern correctly checks the signal (line 856):
if (signal.aborted) {
resolver(new ProtocolError(ProtocolErrorCode.InternalError, 'Task cancelled or completed'));
break;
}
Impact
On multi-tenant servers, a single cancelled long-running tool leaks a polling loop per cancelled request. Over time this accumulates.
Suggested fix
while (task.status !== 'completed' && task.status !== 'failed' && task.status !== 'cancelled') {
if (ctx.mcpReq.signal.aborted) {
throw new ProtocolError(ProtocolErrorCode.RequestCancelled, 'Request cancelled during task polling');
}
await new Promise(resolve => setTimeout(resolve, pollInterval));
// ...
}
- Dominant language
- TypeScript
- Stars
- 13.4k
- Forks
- 2.2k
- Avg merge
- 4d 18h
- Merged PRs (30d)
- 6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from modelcontextprotocol/typescript-sdk
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
v1 v2
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Auth metadata discovery: fallback URL built on resource host instead of authorization-server host Openv1 v2
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
v1 v2
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
modelcontextprotocol/typescript-sdk#2783 · 1 comment ·
-
v1 v2
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
modelcontextprotocol/typescript-sdk#2773 · 1 comment ·
All issues in modelcontextprotocol/typescript-sdk
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
mksglu/context-mode#1200 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
jaegertracing/jaeger-ui#4506 ·
-
area:desktop area:ui bug platform:macos
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
anthropics/claude-code#96687 ·
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
AOSSIE-Org/DebateAI#582 · 2 comments ·
-
📕documentation
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
db-ux-design-system/core-web#8239 ·