Skip to content

Commit 2b07efd

Browse files
Bump protocol version to 3 and guard fallback RPC calls
- Bump SDK_PROTOCOL_VERSION from 2 to 3 to match runtime breaking change - Wrap fallback RPC calls in _executeToolAndRespond and _executePermissionAndRespond with try/catch to prevent unhandled rejections if the connection is disposed mid-flight Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 3d30316 commit 2b07efd

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

nodejs/src/sdkProtocolVersion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* The SDK protocol version.
99
* This must match the version expected by the copilot-agent-runtime server.
1010
*/
11-
export const SDK_PROTOCOL_VERSION = 2;
11+
export const SDK_PROTOCOL_VERSION = 3;
1212

1313
/**
1414
* Gets the SDK protocol version.

nodejs/src/session.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,11 @@ export class CopilotSession {
370370
} catch (error) {
371371
const message =
372372
error instanceof Error ? error.message : String(error);
373-
await this.rpc.tools.handlePendingToolCall({ requestId, error: message });
373+
try {
374+
await this.rpc.tools.handlePendingToolCall({ requestId, error: message });
375+
} catch {
376+
// Connection may have been disposed; nothing more we can do.
377+
}
374378
}
375379
}
376380

@@ -388,12 +392,16 @@ export class CopilotSession {
388392
});
389393
await this.rpc.permissions.handlePendingPermissionRequest({ requestId, result });
390394
} catch (_error) {
391-
await this.rpc.permissions.handlePendingPermissionRequest({
392-
requestId,
393-
result: {
394-
kind: "denied-no-approval-rule-and-could-not-request-from-user",
395-
},
396-
});
395+
try {
396+
await this.rpc.permissions.handlePendingPermissionRequest({
397+
requestId,
398+
result: {
399+
kind: "denied-no-approval-rule-and-could-not-request-from-user",
400+
},
401+
});
402+
} catch {
403+
// Connection may have been disposed; nothing more we can do.
404+
}
397405
}
398406
}
399407

0 commit comments

Comments
 (0)