Skip to content

Commit 8d6679c

Browse files
dev: Command to force IDE ExtHost to crash
Signed-off-by: nkomonen-amazon <[email protected]>
1 parent 1e462f9 commit 8d6679c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-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: 16 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,16 @@ async function expireSsoConnections() {
435441
)
436442
}
437443

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

0 commit comments

Comments
 (0)