1- /*!
2- * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
1+ /*! * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
32 * SPDX-License-Identifier: Apache-2.0
43 */
54
@@ -59,6 +58,12 @@ const appTypeSettingsMap: Record<string, string> = {
5958 [ AppType . CodeEditor as string ] : 'CodeEditorAppSettings' ,
6059} as const
6160
61+ export const waitForAppConfig = {
62+ softTimeoutRetries : 12 ,
63+ hardTimeoutRetries : 120 ,
64+ intervalMs : 5000 ,
65+ }
66+
6267export interface SagemakerSpaceApp extends SpaceDetails {
6368 App ?: AppDetails
6469 DomainSpaceKey : string
@@ -364,10 +369,9 @@ export class SagemakerClient extends ClientWrapper<SageMakerClient> {
364369 domainId : string ,
365370 spaceName : string ,
366371 appType : string ,
367- maxRetries = 30 ,
368- intervalMs = 5000
372+ progress ?: vscode . Progress < { message ?: string ; increment ?: number } >
369373 ) : Promise < void > {
370- for ( let attempt = 0 ; attempt < maxRetries ; attempt ++ ) {
374+ for ( let attempt = 0 ; attempt < waitForAppConfig . hardTimeoutRetries ; attempt ++ ) {
371375 const { Status } = await this . describeApp ( {
372376 DomainId : domainId ,
373377 SpaceName : spaceName ,
@@ -383,7 +387,13 @@ export class SagemakerClient extends ClientWrapper<SageMakerClient> {
383387 throw new ToolkitError ( `App failed to start. Status: ${ Status } ` )
384388 }
385389
386- await sleep ( intervalMs )
390+ if ( attempt === waitForAppConfig . softTimeoutRetries ) {
391+ progress ?. report ( {
392+ message : `Starting the space is taking longer than usual. The space will connect when ready` ,
393+ } )
394+ }
395+
396+ await sleep ( waitForAppConfig . intervalMs )
387397 }
388398
389399 throw new ToolkitError ( `Timed out waiting for app "${ spaceName } " to reach "InService" status.` )
0 commit comments