Skip to content

Commit ab0664b

Browse files
authored
fix(appbuilder): call to getResolvedShellEnv may hang #5954
## Problem recent change to getResolvedShellEnv cause test to stall ## Solution Change return back to resolve in promise
1 parent d4a28eb commit ab0664b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { asEnvironmentVariables } from '../../auth/credentials/utils'
2020
import { getIAMConnection } from '../../auth/utils'
2121
import { ChildProcess } from '../utilities/processUtils'
2222

23-
let unixShellEnvPromise: Promise<typeof process.env> | undefined = undefined
23+
let unixShellEnvPromise: Promise<typeof process.env | void> | undefined = undefined
2424
let envCacheExpireTime: number
2525

2626
export interface IProcessEnvironment {
@@ -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 | undefined> {
142+
export async function getResolvedShellEnv(env?: IProcessEnvironment): Promise<typeof process.env | void> {
143143
if (!env) {
144144
env = process.env
145145
}
@@ -176,7 +176,7 @@ export async function getResolvedShellEnv(env?: IProcessEnvironment): Promise<ty
176176
if (!unixShellEnvPromise || Date.now() > envCacheExpireTime) {
177177
// cache valid for 5 minutes
178178
envCacheExpireTime = Date.now() + 5 * 60 * 1000
179-
unixShellEnvPromise = new Promise<NodeJS.ProcessEnv>(async (resolve, reject) => {
179+
unixShellEnvPromise = new Promise<NodeJS.ProcessEnv | void>(async (resolve, reject) => {
180180
const timeout = new Timeout(10000)
181181

182182
// Resolve shell env and handle errors
@@ -185,11 +185,11 @@ export async function getResolvedShellEnv(env?: IProcessEnvironment): Promise<ty
185185
if (shellEnv && Object.keys(shellEnv).length > 0) {
186186
resolve(shellEnv)
187187
} else {
188-
return undefined
188+
resolve()
189189
}
190190
} catch {
191191
// failed resolve should not affect other feature.
192-
return undefined
192+
resolve()
193193
}
194194
})
195195
}

0 commit comments

Comments
 (0)