@@ -41,6 +41,7 @@ export type DevFunction =
4141 | 'deleteSsoConnections'
4242 | 'expireSsoConnections'
4343 | 'editAuthConnections'
44+ | 'forceIdeCrash'
4445
4546export 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+
438454async 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