handleAutomaticTaskPolling ignores AbortSignal; cancelled requests poll indefinitely
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 74/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- typescript
Hướng nghiên cứu
Bắt đầu trong packages/server/src/server/mcp.ts tại handleAutomaticTaskPolling và so sánh vòng lặp polling của nó với việc kiểm tra signal trong taskManager.ts quanh dòng 856. Xác nhận rằng ctx.mcpReq.signal bị hủy sẽ dừng polling với lỗi hủy đã nêu, đồng thời kiểm tra rằng việc polling các task không bị hủy vẫn đi đến hoàn tất hoặc thất bại.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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));
// ...
}
- Ngôn ngữ chính
- TypeScript
- Star
- 13.4k
- Fork
- 2.2k
- Merge trung bình
- 4 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 6
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của modelcontextprotocol/typescript-sdk
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
v1 v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Auth metadata discovery: fallback URL built on resource host instead of authorization-server host Đang mởv1 v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
v1 v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
modelcontextprotocol/typescript-sdk#2783 · 1 bình luận ·
-
v1 v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
modelcontextprotocol/typescript-sdk#2773 · 1 bình luận ·
Tất cả issue của modelcontextprotocol/typescript-sdk
Issue tương tự
-
bug(cli): hapi doctor inline-media prints a fabricated B:\ helper-script path in packaged installs Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Crush Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
catppuccin/catppuccin#3125 ·
-
Add a SECURITY.md Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
ElementsProject/cln-application#167 · 1 bình luận · 1 reaction ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Quantco/pnpm-licenses#17 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100