()
| 490 | this.onControlRequestSent(message) |
| 491 | } |
| 492 | const aborted = () => { |
| 493 | this.outbound.enqueue({ |
| 494 | type: 'control_cancel_request', |
| 495 | request_id: requestId, |
| 496 | }) |
| 497 | // Immediately reject the outstanding promise, without |
| 498 | // waiting for the host to acknowledge the cancellation. |
| 499 | const request = this.pendingRequests.get(requestId) |
| 500 | if (request) { |
| 501 | // Track the tool_use ID as resolved before rejecting, so that a |
| 502 | // late response from the host is ignored by the orphan handler. |
| 503 | this.trackResolvedToolUseId(request.request) |
| 504 | request.reject(new AbortError()) |
| 505 | } |
| 506 | } |
| 507 | if (signal) { |
| 508 | signal.addEventListener('abort', aborted, { |
| 509 | once: true, |
nothing calls this directly
no test coverage detected