Skip to content

Commit 130c388

Browse files
authored
fix(cloud9: "Attempted to get compute region without initializing" #3606
Problem: since 4e40536 the Toolkit can't load on cloud9: INFO ExtHost [error]: Error: Attempted to get compute region without initializing. at getComputeRegion (/opt/c9/dependencies/aws-toolkit-vscode/…/dist/src/main.js:377606:11) at isCn (/opt/c9/dependencies/aws-toolkit-vscode/…/dist/src/main.js:377457:22) at getIdeProperties (/opt/c9/dependencies/aws-toolkit-vscode/…/dist/src/main.js:377429:11) Solution: Lazy-load `SamCliValidationNotificationAction.label()`.
1 parent 55aafff commit 130c388

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

src/shared/sam/cli/samCliValidationNotification.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,24 @@ const localize = nls.loadMessageBundle()
2424

2525
// Notification Actions
2626
export interface SamCliValidationNotificationAction {
27-
label: string
27+
label(): string
2828
invoke(): Promise<void>
2929
}
3030

3131
const actionGoToSamCli: SamCliValidationNotificationAction = {
32-
label: localize('AWS.samcli.userChoice.visit.install.url', 'Install latest SAM CLI'),
32+
label: () => localize('AWS.samcli.userChoice.visit.install.url', 'Install latest SAM CLI'),
3333
invoke: async () => {
3434
openUrl(samInstallUrl)
3535
},
3636
}
3737

3838
const actionGoToVsCodeMarketplace: SamCliValidationNotificationAction = {
39-
label: localize(
40-
'AWS.samcli.userChoice.update.awstoolkit.url',
41-
'Install latest {0} Toolkit',
42-
getIdeProperties().company
43-
),
39+
label: () =>
40+
localize(
41+
'AWS.samcli.userChoice.update.awstoolkit.url',
42+
'Install latest {0} Toolkit',
43+
getIdeProperties().company
44+
),
4445
invoke: async () => {
4546
showExtensionPage(VSCODE_EXTENSION_ID.awstoolkit)
4647
},
@@ -60,12 +61,12 @@ class DefaultSamCliValidationNotification implements SamCliValidationNotificatio
6061
public async show(): Promise<void> {
6162
const userResponse: string | undefined = await vscode.window.showErrorMessage(
6263
this.message,
63-
...this.actions.map(action => action.label)
64+
...this.actions.map(action => action.label())
6465
)
6566

6667
if (userResponse) {
6768
const responseActions: Promise<void>[] = this.actions
68-
.filter(action => action.label === userResponse)
69+
.filter(action => action.label() === userResponse)
6970
.map(async action => action.invoke())
7071

7172
await Promise.all(responseActions)

src/test/shared/sam/cli/samCliValidationNotification.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ describe('getInvalidSamMsg', async function () {
3434
assert.ok(message.includes('Cannot find SAM CLI'), `unexpected validation message: ${message}`)
3535
assert.strictEqual(actions.length, 1, 'unexpected action count')
3636
assert.strictEqual(
37-
actions[0].label,
37+
actions[0].label(),
3838
actionLabelUpdateSamCli,
39-
`unexpected action label: ${actions[0].label}`
39+
`unexpected action label: ${actions[0].label()}`
4040
)
4141

4242
return fakeSamCliValidationNotification
@@ -83,9 +83,9 @@ describe('getInvalidSamMsg', async function () {
8383
assert.ok(hasMsg && hasVersion, `unexpected validation message: ${message}`)
8484
assert.strictEqual(actions.length, 1, 'unexpected action count')
8585
assert.strictEqual(
86-
actions[0].label,
86+
actions[0].label(),
8787
test.actionLabel,
88-
`unexpected action label: ${actions[0].label}`
88+
`unexpected action label: ${actions[0].label()}`
8989
)
9090

9191
return fakeSamCliValidationNotification

0 commit comments

Comments
 (0)