Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

handleAutomaticTaskPolling ignores AbortSignal; cancelled requests poll indefinitely

Đang mở Phù hợp với người mới
#2,018 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
Lĩnh vực
api, backend

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ả

potentially close
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

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của modelcontextprotocol/typescript-sdk

Tất cả issue của modelcontextprotocol/typescript-sdk

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.