Skip to content

Commit 1d06af7

Browse files
authored
fix(status-bar): invalid status reported when stopping LocalStack externally (#39)
Fix status bar incorrectly reporting LocalStack as starting when stopping in certain scenarios.
1 parent 00ff25a commit 1d06af7

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/utils/localstack-status.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export async function createLocalStackStatusTracker(
3737
};
3838

3939
const deriveStatus = () => {
40-
const newStatus = getLocalStackStatus(containerStatus, healthCheck);
40+
const newStatus = getLocalStackStatus(containerStatus, healthCheck, status);
4141
setStatus(newStatus);
4242
};
4343

@@ -85,11 +85,18 @@ export async function createLocalStackStatusTracker(
8585
function getLocalStackStatus(
8686
containerStatus: ContainerStatus | undefined,
8787
healthCheck: boolean | undefined,
88+
previousStatus?: LocalStackStatus,
8889
): LocalStackStatus {
8990
if (containerStatus === "running") {
9091
if (healthCheck === true) {
9192
return "running";
9293
} else {
94+
// When the LS container is running, and the health check fails:
95+
// - If the previous status was "running", we are likely stopping LS
96+
// - If the previous status was "stopping", we are still stopping LS
97+
if (previousStatus === "running" || previousStatus === "stopping") {
98+
return "stopping";
99+
}
93100
return "starting";
94101
}
95102
} else if (containerStatus === "stopping") {

0 commit comments

Comments
 (0)