From 35396f4a8d3e64e286ea922f5249a843900d27a0 Mon Sep 17 00:00:00 2001 From: Justin Spahr-Summers Date: Sat, 16 Nov 2024 16:31:45 +0000 Subject: [PATCH] Report errors sending cancellation --- src/shared/protocol.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/shared/protocol.ts b/src/shared/protocol.ts index 559d2c20..03dffa77 100644 --- a/src/shared/protocol.ts +++ b/src/shared/protocol.ts @@ -418,14 +418,18 @@ export abstract class Protocol< this._responseHandlers.delete(messageId); this._progressHandlers.delete(messageId); - this._transport?.send({ - jsonrpc: "2.0", - method: "cancelled", - params: { - requestId: messageId, - reason: String(reason), - }, - }); + this._transport + ?.send({ + jsonrpc: "2.0", + method: "cancelled", + params: { + requestId: messageId, + reason: String(reason), + }, + }) + .catch((error) => + this._onerror(new Error(`Failed to send cancellation: ${error}`)), + ); reject(reason); };