From c2f4d2db04373d4a2e1661bce9957c6125023d7f Mon Sep 17 00:00:00 2001 From: Punit Shah Date: Wed, 12 Aug 2026 10:24:44 -0700 Subject: [PATCH] fix: handle cancellation for request id zero --- packages/core-internal/src/shared/protocol.ts | 2 +- packages/core-internal/test/shared/protocol.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core-internal/src/shared/protocol.ts b/packages/core-internal/src/shared/protocol.ts index 0a19770082..ead715f5bf 100644 --- a/packages/core-internal/src/shared/protocol.ts +++ b/packages/core-internal/src/shared/protocol.ts @@ -724,7 +724,7 @@ export abstract class Protocol { } private async _oncancel(notification: CancelledNotification): Promise { - if (!notification.params.requestId) { + if (notification.params.requestId === undefined) { return; } // Handle request cancellation diff --git a/packages/core-internal/test/shared/protocol.test.ts b/packages/core-internal/test/shared/protocol.test.ts index 2ecdc40adc..5b979add5d 100644 --- a/packages/core-internal/test/shared/protocol.test.ts +++ b/packages/core-internal/test/shared/protocol.test.ts @@ -775,7 +775,7 @@ describe('protocol tests', () => { }); describe('notifications/cancelled behavior', () => { - test('should abort request handler when notifications/cancelled is received', async () => { + test('should abort request handler when notifications/cancelled contains requestId 0', async () => { await protocol.connect(transport); // Set up a request handler that checks if it was aborted @@ -788,7 +788,7 @@ describe('protocol tests', () => { }); // Simulate an incoming request - const requestId = 123; + const requestId = 0; if (transport.onmessage) { transport.onmessage({ jsonrpc: '2.0',