Skip to content

Commit 28c2610

Browse files
committed
fix(toolkit): initialize compute region in get call with a default value to fix extension activation failure
1 parent d8548fc commit 28c2610

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/core/src/shared/extensionUtilities.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,15 @@ export async function initializeComputeRegion(
370370

371371
export function getComputeRegion(): string | undefined {
372372
if (computeRegion === notInitialized) {
373-
throw new Error('Attempted to get compute region without initializing.')
373+
// Set a default value immediately to prevent future calls from throwing error
374+
const isC9 = isCloud9()
375+
const isSM = isSageMaker()
376+
computeRegion = isC9 || isSM ? 'unknown' : undefined
377+
// Start async initialization in the background
378+
initializeComputeRegion(undefined, isC9, isSM).catch((e) => {
379+
getLogger().error('Failed to initialize compute region: %s and using a default value: %s', e, computeRegion)
380+
})
374381
}
375-
376382
return computeRegion
377383
}
378384

0 commit comments

Comments
 (0)