When using the MCP TypeScript SDK (SSEClientTransport / StreamableHTTPClientTransport) with Undici instrumentation (e.g., OpenTelemetry), successful MCP POST requests are being reported as aborted.
This happens because close() immediately calls:
this._abortController?.abort()
If a POST response is still being processed, Undici receives the abort signal and marks the span as an error, even though the server returned 200 OK. This results in spans like:
UND_ERR_ABORTED: The operation was aborted
for successful requests.
Impact
- Successful MCP requests show up as failed in traces
- Undici logs aborted errors
- Misleading telemetry in distributed tracing
- Connections stay open until Undici’s idle timeout (~10–14 seconds)
Reproduction
-
Enable OTel Undici instrumentation
-
Use SSEClientTransport or StreamableHTTPClientTransport
-
Send any POST request (initialize, callTool, etc.)
-
Immediately call client.close()
-
Observe:
- Response is 200 OK
- Undici reports
UND_ERR_ABORTED
- Span is marked as failed
Request
Could the SDK:
- Avoid calling
AbortController.abort() while requests are still in-flight
- Optionally provide a graceful close mode that waits for active requests to finish
This would prevent Undici from misclassifying successful MCP requests as aborted and keep telemetry accurate.