Skip to content

fix: check AbortSignal in handleAutomaticTaskPolling to stop cancelled requests#2019

Open
blackwell-systems wants to merge 3 commits intomodelcontextprotocol:mainfrom
blackwell-systems:fix/automatic-task-polling-abort-signal
Open

fix: check AbortSignal in handleAutomaticTaskPolling to stop cancelled requests#2019
blackwell-systems wants to merge 3 commits intomodelcontextprotocol:mainfrom
blackwell-systems:fix/automatic-task-polling-abort-signal

Conversation

@blackwell-systems
Copy link
Copy Markdown

Summary

handleAutomaticTaskPolling polls a task store in a while loop without checking ctx.mcpReq.signal.aborted. Cancelled requests continue polling indefinitely, leaking server resources.

Motivation and Context

The taskManager.ts implementation correctly checks the signal for the same polling pattern (line 856). This brings handleAutomaticTaskPolling in line with that behavior.

How Has This Been Tested?

Existing tests pass. The change adds an early exit condition that only fires when the request's AbortSignal has been triggered (client cancellation).

Fixes #2018

…d requests

The while loop in handleAutomaticTaskPolling polls indefinitely
without checking ctx.mcpReq.signal.aborted. If a client cancels
the request, the poll loop continues consuming server resources.

The taskManager.ts implementation of the same pattern correctly
checks signal.aborted (line 856). This brings handleAutomaticTaskPolling
in line with that behavior.

Fixes modelcontextprotocol#2018
@blackwell-systems blackwell-systems requested a review from a team as a code owner May 5, 2026 04:40
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 5, 2026

🦋 Changeset detected

Latest commit: d1df061

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@modelcontextprotocol/server Patch
@modelcontextprotocol/express Patch
@modelcontextprotocol/fastify Patch
@modelcontextprotocol/hono Patch
@modelcontextprotocol/node Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 5, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@2019

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@2019

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@2019

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@2019

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@2019

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@2019

commit: d1df061

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

handleAutomaticTaskPolling ignores AbortSignal; cancelled requests poll indefinitely

1 participant