diff --git a/src/utils/localstack-status.ts b/src/utils/localstack-status.ts index f89525c..bfd63a2 100644 --- a/src/utils/localstack-status.ts +++ b/src/utils/localstack-status.ts @@ -37,7 +37,7 @@ export async function createLocalStackStatusTracker( }; const deriveStatus = () => { - const newStatus = getLocalStackStatus(containerStatus, healthCheck); + const newStatus = getLocalStackStatus(containerStatus, healthCheck, status); setStatus(newStatus); }; @@ -85,11 +85,18 @@ export async function createLocalStackStatusTracker( function getLocalStackStatus( containerStatus: ContainerStatus | undefined, healthCheck: boolean | undefined, + previousStatus?: LocalStackStatus, ): LocalStackStatus { if (containerStatus === "running") { if (healthCheck === true) { return "running"; } else { + // When the LS container is running, and the health check fails: + // - If the previous status was "running", we are likely stopping LS + // - If the previous status was "stopping", we are still stopping LS + if (previousStatus === "running" || previousStatus === "stopping") { + return "stopping"; + } return "starting"; } } else if (containerStatus === "stopping") {