File tree Expand file tree Collapse file tree 1 file changed +14
-10
lines changed
Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -26,18 +26,22 @@ async function fetchHealth(): Promise<boolean> {
2626 return false ;
2727 }
2828}
29-
3029async function fetchLocalStackSessionId ( ) : Promise < string > {
31- try {
32- // TODO info endpoint is not available immediately
33- // potentially improve this later for tracking "vscode:emulator:started"
34- const infoResponse = await fetch ( "http://localhost:4566/_localstack/info" ) ;
35- if ( infoResponse . ok ) {
36- const info = ( await infoResponse . json ( ) ) as { session_id ?: string } ;
37- return info . session_id ?? "" ;
30+ // retry a few times to allow LocalStack to start up and info become available
31+ for ( let attempt = 0 ; attempt < 5 ; attempt ++ ) {
32+ try {
33+ const response = await fetch ( "http://localhost:4566/_localstack/info" ) ;
34+ if ( response . ok ) {
35+ const json = await response . json ( ) ;
36+ if ( typeof json === "object" && json !== null && "session_id" in json ) {
37+ return ( json as { session_id ?: string } ) . session_id ?? "" ;
38+ }
39+ return "" ;
40+ }
41+ } catch {
42+ // ignore error and retry
3843 }
39- } catch {
40- // unable to fetch session id
44+ await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) ) ;
4145 }
4246 return "" ;
4347}
You can’t perform that action at this time.
0 commit comments