@@ -61,7 +61,7 @@ export function createLocalStackInstanceStatusTracker(
6161 } ) ;
6262
6363 status . onChange ( ( newStatus ) => {
64- outputChannel . trace ( `[localstack-status] localstack =${ newStatus } ` ) ;
64+ outputChannel . trace ( `[localstack-instances- status] status =${ newStatus } ` ) ;
6565
6666 if ( newStatus === "running" ) {
6767 healthCheckStatusTracker . stop ( ) ;
@@ -89,9 +89,11 @@ export function createLocalStackInstanceStatusTracker(
8989 return status . value ( ) ;
9090 } ,
9191 forceContainerStatus ( newContainerStatus ) {
92- if ( containerStatus !== newContainerStatus ) {
93- containerStatus = newContainerStatus ;
94- deriveStatus ( ) ;
92+ containerStatus = newContainerStatus ;
93+ if ( newContainerStatus === "running" ) {
94+ status . setValue ( "starting" ) ;
95+ } else if ( newContainerStatus === "stopping" ) {
96+ status . setValue ( "stopping" ) ;
9597 }
9698 } ,
9799 onChange ( callback ) {
@@ -107,24 +109,37 @@ function getLocalStackStatus(
107109 containerStatus : LocalStackContainerStatus | undefined ,
108110 healthStatus : HealthStatus | undefined ,
109111 previousStatus ?: LocalStackInstanceStatus ,
110- ) : LocalStackInstanceStatus {
111- if ( containerStatus === "running" ) {
112- if ( healthStatus === "healthy" ) {
113- return "running" ;
114- } else {
115- // When the LS container is running, and the health check fails:
116- // - If the previous status was "running", we are likely stopping LS
117- // - If the previous status was "stopping", we are still stopping LS
118- if ( previousStatus === "running" || previousStatus === "stopping" ) {
119- return "stopping" ;
120- }
121- return "starting" ;
112+ ) : LocalStackInstanceStatus | undefined {
113+ // There's no LS container status yet, so can't derive LS instance status.
114+ if ( containerStatus === undefined ) {
115+ return undefined ;
116+ }
117+
118+ if ( containerStatus === "running" && healthStatus === "healthy" ) {
119+ return "running" ;
120+ }
121+
122+ if ( containerStatus === "running" && healthStatus === "unhealthy" ) {
123+ // When the LS container is running, and the health check fails:
124+ // - If the previous status was "running", we are likely stopping LS
125+ // - If the previous status was "stopping", we are still stopping LS
126+ if ( previousStatus === "running" || previousStatus === "stopping" ) {
127+ return "stopping" ;
122128 }
123- } else if ( containerStatus === "stopping" ) {
129+
130+ return "starting" ;
131+ }
132+
133+ if ( containerStatus === "running" && healthStatus === undefined ) {
134+ // return previousStatus;
135+ return undefined ;
136+ }
137+
138+ if ( containerStatus === "stopping" ) {
124139 return "stopping" ;
125- } else {
126- return "stopped" ;
127140 }
141+
142+ return "stopped" ;
128143}
129144
130145type HealthStatus = "healthy" | "unhealthy" ;
0 commit comments