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',