You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(core): consolidate per-request cleanup into .finally()
Moves _responseHandlers.delete and _cleanupTimeout from four scattered
exit paths into the .finally() block alongside the abort listener
removal. This also fixes two latent bugs where the taskManager error
callback and transport.send().catch() paths were only calling
_cleanupTimeout, leaking entries in _responseHandlers.
_progressHandlers.delete stays at the error-path call sites because
_onresponse deletes it conditionally (preserveProgress for task flows)
and putting it in .finally() would override that.
Copy file name to clipboardExpand all lines: .changeset/fix-abort-listener-leak.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,4 +2,4 @@
2
2
'@modelcontextprotocol/core': patch
3
3
---
4
4
5
-
Fix abort signal listener leak in outbound requests. When a caller reuses a single `AbortSignal` across multiple requests (common for session-scoped cancellation), the SDK previously attached a new listener per request without ever removing it. The listener is now detached when the request settles.
5
+
Consolidate per-request cleanup in `_requestWithSchema` into a single `.finally()` block. This fixes an abort signal listener leak (listeners accumulated when a caller reused one `AbortSignal` across requests) and two cases where `_responseHandlers` entries leaked on send-failure paths.
0 commit comments