Skip to content

Commit 595ce5e

Browse files
dev: Command to force IDE ExtHost to crash
Signed-off-by: nkomonen-amazon <[email protected]>
1 parent 0c4289b commit 595ce5e

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

packages/amazonq/src/extensionNode.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ async function setupDevMode(context: vscode.ExtensionContext) {
7777
'deleteSsoConnections',
7878
'expireSsoConnections',
7979
'editAuthConnections',
80+
'forceIdeCrash',
8081
],
8182
}
8283

packages/core/src/dev/activation.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export type DevFunction =
4141
| 'deleteSsoConnections'
4242
| 'expireSsoConnections'
4343
| 'editAuthConnections'
44+
| 'forceIdeCrash'
4445

4546
export type DevOptions = {
4647
context: vscode.ExtensionContext
@@ -105,6 +106,11 @@ const menuOptions: Record<DevFunction, MenuOption> = {
105106
detail: 'Opens editor to all Auth Connections the extension is using.',
106107
executor: editSsoConnections,
107108
},
109+
forceIdeCrash: {
110+
label: 'Crash: Force IDE ExtHost Crash',
111+
detail: `Will SIGKILL ExtHost with pid, ${process.pid}, but IDE will not crash itself.`,
112+
executor: forceQuitIde,
113+
},
108114
}
109115

110116
/**
@@ -435,6 +441,15 @@ async function expireSsoConnections() {
435441
)
436442
}
437443

444+
export function forceQuitIde() {
445+
// This current process is the ExtHost. Killing it will cause all the extensions to crash
446+
// for the specific IDE instance.
447+
// The PPID does not seem to be the IDE instance but the root VS Code process, killing
448+
// this crashes all VS Code instances.
449+
const vsCodePid = process.pid
450+
process.kill(vsCodePid, 'SIGKILL') // SIGTERM would be the graceful shutdown
451+
}
452+
438453
async function showState(path: string) {
439454
const uri = vscode.Uri.parse(`aws-dev2://state/${path}-${targetContext.extension.id}`)
440455
const doc = await vscode.workspace.openTextDocument(uri)

0 commit comments

Comments
 (0)