Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/shared/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -857,12 +857,6 @@ export abstract class Protocol<SendRequestT extends Request, SendNotificationT e
const { progressToken, ...params } = notification.params;
const messageId = Number(progressToken);

const handler = this._progressHandlers.get(messageId);
if (!handler) {
this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(notification)}`));
return;
}

const responseHandler = this._responseHandlers.get(messageId);
const timeoutInfo = this._timeoutInfo.get(messageId);

Expand All @@ -874,11 +868,21 @@ export abstract class Protocol<SendRequestT extends Request, SendNotificationT e
this._responseHandlers.delete(messageId);
this._progressHandlers.delete(messageId);
this._cleanupTimeout(messageId);
const handler = this._progressHandlers.get(messageId);
if (handler) {
handler(params);
}
responseHandler(error as Error);
return;
}
}

const handler = this._progressHandlers.get(messageId);
if (!handler) {
this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(notification)}`));
return;
}

handler(params);
}

Expand Down
Loading