Skip to content

Commit 9794447

Browse files
committed
fix(smus): Improve error handling when the Space takes too long to start
1 parent e1abbe6 commit 9794447

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

packages/core/src/awsService/sagemaker/commands.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,8 @@ async function handleRunningSpaceWithDisabledAccess(
332332
await client.waitForAppInService(
333333
node.spaceApp.DomainId!,
334334
spaceName,
335-
node.spaceApp.SpaceSettingsSummary!.AppType!
335+
node.spaceApp.SpaceSettingsSummary!.AppType!,
336+
progress
336337
)
337338
await tryRemoteConnection(node, ctx, progress)
338339
} catch (err: any) {
@@ -376,7 +377,8 @@ async function handleStoppedSpace(
376377
await client.waitForAppInService(
377378
node.spaceApp.DomainId!,
378379
spaceName,
379-
node.spaceApp.SpaceSettingsSummary!.AppType!
380+
node.spaceApp.SpaceSettingsSummary!.AppType!,
381+
progress
380382
)
381383
await tryRemoteConnection(node, ctx, progress)
382384
}

packages/core/src/shared/clients/sagemaker.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,12 @@ export class SagemakerClient extends ClientWrapper<SageMakerClient> {
364364
domainId: string,
365365
spaceName: string,
366366
appType: string,
367-
maxRetries = 30,
367+
progress?: vscode.Progress<{ message?: string; increment?: number }>,
368+
softTimeoutRetries = 12, // 1 minute
369+
hardTimeoutRetries = 120, // 10 minutes
368370
intervalMs = 5000
369371
): Promise<void> {
370-
for (let attempt = 0; attempt < maxRetries; attempt++) {
372+
for (let attempt = 0; attempt < hardTimeoutRetries; attempt++) {
371373
const { Status } = await this.describeApp({
372374
DomainId: domainId,
373375
SpaceName: spaceName,
@@ -383,6 +385,12 @@ export class SagemakerClient extends ClientWrapper<SageMakerClient> {
383385
throw new ToolkitError(`App failed to start. Status: ${Status}`)
384386
}
385387

388+
if (attempt === softTimeoutRetries) {
389+
progress?.report({
390+
message: `Starting the space is taking longer than usual. Will connect when ready.`,
391+
})
392+
}
393+
386394
await sleep(intervalMs)
387395
}
388396

packages/core/src/test/shared/clients/sagemakerClient.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ describe('SagemakerClient.waitForAppInService', function () {
252252
describeAppStub.resolves({ Status: 'Pending' })
253253

254254
await assert.rejects(
255-
client.waitForAppInService('domain1', 'space1', 'CodeEditor', 2, 10),
255+
client.waitForAppInService('domain1', 'space1', 'CodeEditor', undefined, 2, 2, 10),
256256
/Timed out waiting for app/
257257
)
258258
})

0 commit comments

Comments
 (0)