From db6e15e2214629fb2c09b8bf82c39ab53ebd7c30 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 29 Nov 2023 11:06:04 -0800 Subject: [PATCH] Do not throw if initializing deactivate script fails (#22566) For #20950 --- src/client/terminals/envCollectionActivation/service.ts | 4 +++- .../activation/terminalEnvVarCollectionService.unit.test.ts | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/client/terminals/envCollectionActivation/service.ts b/src/client/terminals/envCollectionActivation/service.ts index 68c098c4c928..b9a9fc17b3d5 100644 --- a/src/client/terminals/envCollectionActivation/service.ts +++ b/src/client/terminals/envCollectionActivation/service.ts @@ -243,7 +243,9 @@ export class TerminalEnvVarCollectionService implements IExtensionActivationServ envVarCollection.description = description; await this.trackTerminalPrompt(shell, resource, env); - await this.terminalDeactivateService.initializeScriptParams(shell); + await this.terminalDeactivateService.initializeScriptParams(shell).catch((ex) => { + traceError(`Failed to initialize deactivate script`, shell, ex); + }); } private isPromptSet = new Map(); diff --git a/src/test/interpreters/activation/terminalEnvVarCollectionService.unit.test.ts b/src/test/interpreters/activation/terminalEnvVarCollectionService.unit.test.ts index 55e0b80d3e1e..daf3150fdbd0 100644 --- a/src/test/interpreters/activation/terminalEnvVarCollectionService.unit.test.ts +++ b/src/test/interpreters/activation/terminalEnvVarCollectionService.unit.test.ts @@ -341,6 +341,7 @@ suite('Terminal Environment Variable Collection Service', () => { test('Also prepend deactivate script location if available', async () => { reset(terminalDeactivateService); + when(terminalDeactivateService.initializeScriptParams(anything())).thenResolve(); when(terminalDeactivateService.getScriptLocation(anything(), anything())).thenResolve('scriptLocation'); const processEnv = { PATH: 'hello/1/2/3' }; reset(environmentActivationService); @@ -409,6 +410,7 @@ suite('Terminal Environment Variable Collection Service', () => { test('Prepend full PATH with separator otherwise', async () => { reset(terminalDeactivateService); + when(terminalDeactivateService.initializeScriptParams(anything())).thenResolve(); when(terminalDeactivateService.getScriptLocation(anything(), anything())).thenResolve('scriptLocation'); const processEnv = { PATH: 'hello/1/2/3' }; reset(environmentActivationService);