Skip to content

Commit fc5e43c

Browse files
committed
fix cancellation to cancel entire process
1 parent b0b4d6d commit fc5e43c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/shared/remoteSession.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import * as vscode from 'vscode'
77
import * as nls from 'vscode-nls'
8-
const localize = nls.loadMessageBundle()
98

109
import { Settings } from '../shared/settings'
1110
import { showConfirmationMessage, showMessageWithCancel } from './utilities/messages'
@@ -23,6 +22,8 @@ import { IamClient } from './clients/iamClient'
2322
import { IAM } from 'aws-sdk'
2423
import { getIdeProperties } from './extensionUtilities'
2524

25+
const localize = nls.loadMessageBundle()
26+
2627
export interface MissingTool {
2728
readonly name: 'code' | 'ssm' | 'ssh'
2829
readonly reason?: string
@@ -204,14 +205,19 @@ export async function promptToAddInlinePolicy(client: IamClient, roleArn: string
204205

205206
async function addInlinePolicyWithDelay(client: IamClient, roleArn: string) {
206207
const timeout = new Timeout(policyAttachDelay)
207-
await showMessageWithCancel(`Adding Inline Policy to ${roleArn}`, timeout)
208+
const message = `Adding Inline Policy to ${roleArn}`
209+
await showMessageWithCancel(message, timeout)
208210
await addSsmActionsToInlinePolicy(client, roleArn)
209211

210212
function delay(ms: number) {
211213
return new Promise(resolve => setTimeout(resolve, ms))
212214
}
213215

214-
await delay(policyAttachDelay).finally(() => timeout.cancel())
216+
await delay(policyAttachDelay - 100)
217+
if (timeout.completed) {
218+
throw new CancellationError('user')
219+
}
220+
timeout.cancel()
215221
}
216222

217223
function getFormattedSsmActions() {

0 commit comments

Comments
 (0)