Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/utils/localstack-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function createLocalStackStatusTracker(
};

const deriveStatus = () => {
const newStatus = getLocalStackStatus(containerStatus, healthCheck);
const newStatus = getLocalStackStatus(containerStatus, healthCheck, status);
setStatus(newStatus);
};

Expand Down Expand Up @@ -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") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if previousStatus is stopping, shouldn't we return starting?

Copy link
Collaborator Author

@skyrpex skyrpex Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good question and I guess it deserves an explanatory comment in-code.

Without the || previousStatus === "stopping" check, we get a wrong behavior:

  • When stopping LS externally, we would first go from "running" to "stopping", which is correct.
  • But the next health check will go from "stopping" to "starting", which is wrong.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was tricky, and the explanation is very clear 🙌🏼

return "stopping";
}
return "starting";
}
} else if (containerStatus === "stopping") {
Expand Down
Loading