Skip to content

Commit 064ef63

Browse files
committed
test
1 parent 34b695a commit 064ef63

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

packages/core/src/shared/env/resolveEnv.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export async function mergeResolvedShellPath(env: IProcessEnvironment): Promise<
139139
* - we hit a timeout of `MAX_SHELL_RESOLVE_TIME`
140140
* - any other error from spawning a shell to figure out the environment
141141
*/
142-
export async function getResolvedShellEnv(env?: IProcessEnvironment): Promise<typeof process.env> {
142+
export async function getResolvedShellEnv(env?: IProcessEnvironment): Promise<typeof process.env | undefined> {
143143
if (!env) {
144144
env = process.env
145145
}

packages/core/src/shared/sam/localLambdaRunner.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,7 @@ async function invokeLambdaHandler(
212212
return config
213213
.samLocalInvokeCommand!.invoke({
214214
options: {
215-
env: await getSpawnEnv({
216-
...process.env,
217-
...env,
218-
}),
215+
env: env,
219216
},
220217
command: samCommand,
221218
args: samArgs,
@@ -236,7 +233,7 @@ async function invokeLambdaHandler(
236233
templatePath: config.templatePath,
237234
eventPath: config.eventPayloadFile,
238235
environmentVariablePath: config.envFile,
239-
environmentVariables: await getSpawnEnv(env),
236+
environmentVariables: env,
240237
invoker: config.samLocalInvokeCommand!,
241238
dockerNetwork: config.sam?.dockerNetwork,
242239
debugPort: debugPort,
@@ -290,15 +287,16 @@ export async function runLambdaFunction(
290287
getLogger().info(localize('AWS.output.sam.local.startRun', 'Preparing to run locally: {0}', config.handlerName))
291288
}
292289

293-
const envVars = {
290+
const envVars = await getSpawnEnv({
291+
...process.env,
294292
...(config.aws?.region ? { AWS_DEFAULT_REGION: config.aws.region } : {}),
295-
}
293+
})
296294

297295
const settings = SamCliSettings.instance
298296
const timer = new Timeout(settings.getLocalInvokeTimeout())
299297

300298
// TODO: refactor things to not mutate the config
301-
config.templatePath = await buildLambdaHandler(timer, await getSpawnEnv(envVars), config, settings)
299+
config.templatePath = await buildLambdaHandler(timer, envVars, config, settings)
302300

303301
await onAfterBuild()
304302
timer.refresh()
@@ -315,7 +313,7 @@ export async function runLambdaFunction(
315313

316314
// SAM CLI and any API requests are executed in parallel
317315
// A failure from either is a failure for the whole invocation
318-
const [process] = await Promise.all([invokeLambdaHandler(timer, envVars, config, settings), apiRequest]).catch(
316+
const [processConst] = await Promise.all([invokeLambdaHandler(timer, envVars, config, settings), apiRequest]).catch(
319317
(err) => {
320318
timer.cancel()
321319
throw err
@@ -329,7 +327,7 @@ export async function runLambdaFunction(
329327
const terminationListener = vscode.debug.onDidTerminateDebugSession((session) => {
330328
const config = session.configuration as SamLaunchRequestArgs
331329
if (config.invokeTarget?.target === 'api') {
332-
stopApi(process, config)
330+
stopApi(processConst, config)
333331
}
334332
})
335333

0 commit comments

Comments
 (0)