[v2] Expose per-request stream end (onRequestStreamEnd) in RequestOptions for custom long-lived requests

Đang mở
#3,060 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
68/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
api, backend

Hướng nghiên cứu

Start by reading RequestOptions in packages/core-internal/src/shared/protocol.ts and the transport.send(...) call in _requestWithSchemaViaCodec; compare how Client.listen() forwards onRequestStreamEnd. Check the existing tests for protocol requests and stream transports, then add coverage showing a request can detect its response stream ending before a JSON-RPC response. Done means the callback or chosen rejection behavior is exposed through request options and tested, while transports without per-request streams continue to work.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

v1 v2
Summary

Protocol.request() gives callers no way to learn that the per-request response stream ended. The client transport already supports this: TransportSendOptions.onRequestStreamEnd, which StreamableHTTPClientTransport fires when a request's SSE response ends. But only Client.listen() uses it (it calls transport.send() directly). RequestOptions has no equivalent, and _requestWithSchemaViaCodec passes requestSignal to transport.send() but not onRequestStreamEnd.

Why it matters

Extensions that define long-lived streaming requests can't detect a dead stream promptly. One example is events/stream from the Events extension (SEP-3415, see #2945). If the server restarts mid-stream, the POST's SSE body ends without a JSON-RPC response. The pending request then waits for its timeout, or for an application-level heartbeat watchdog. In @mastra/mcp we detect this through a 30s heartbeat window, so it takes up to 60s. subscriptions/listen gets immediate detection because it uses the transport option directly.

This is the request-level counterpart of #2739, which covers non-streaming requests left pending when their SSE response ends.

Proposal

Add an option to RequestOptions, for example onRequestStreamEnd?: () => void, and forward it to transport.send() the same way requestSignal is forwarded. Alternatively, reject the pending request with a distinct error when its stream ends before a response arrives. Transports with no per-request stream (stdio, InMemory) would keep ignoring it, as they do today.

Versions

We hit this on @modelcontextprotocol/[email protected]. It's still present on main (c05225a6): see RequestOptions in packages/core-internal/src/shared/protocol.ts and the transport.send(...) call in _requestWithSchemaViaCodec.

Ngôn ngữ chính
TypeScript
Star
13.8k
Fork
2.5k
Merge trung bình
6 ngày 23 giờ
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

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.