From 30a5a71b4c9a01f8487212a0dc5fbc6385811f95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Pallar=C3=A9s?= Date: Wed, 3 Sep 2025 16:30:59 +0200 Subject: [PATCH 1/2] feat: abort health check after 500ms --- src/utils/localstack-status.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/utils/localstack-status.ts b/src/utils/localstack-status.ts index 127c615..f3814f3 100644 --- a/src/utils/localstack-status.ts +++ b/src/utils/localstack-status.ts @@ -81,14 +81,20 @@ function getLocalStackStatus( } } -async function fetchHealth(): Promise { - // health is ok in the majority of use cases, however, determining status based on it can be flaky. - // for example, if localstack becomes unhealthy while running for reasons other that stop then reporting "stopping" may be misleading. - // though we don't know if it happens often. +async function fetchHealth(outputChannel: LogOutputChannel): Promise { + // Abort the fetch if it takes more than 500ms. + const controller = new AbortController(); + setTimeout(() => controller.abort(), 500); + try { - const response = await fetch("http://localhost:4566/_localstack/health"); + // health is ok in the majority of use cases, however, determining status based on it can be flaky. + // for example, if localstack becomes unhealthy while running for reasons other that stop then reporting "stopping" may be misleading. + // though we don't know if it happens often. + const response = await fetch("http://localhost:4566/_localstack/health", { + signal: controller.signal, + }); return response.ok; - } catch { + } catch (err) { return false; } } From 20f32d2030597fe92964a9bd37f41c821927db49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Pallar=C3=A9s?= Date: Wed, 3 Sep 2025 16:35:34 +0200 Subject: [PATCH 2/2] wip --- src/utils/localstack-status.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/localstack-status.ts b/src/utils/localstack-status.ts index f3814f3..da86af2 100644 --- a/src/utils/localstack-status.ts +++ b/src/utils/localstack-status.ts @@ -81,7 +81,7 @@ function getLocalStackStatus( } } -async function fetchHealth(outputChannel: LogOutputChannel): Promise { +async function fetchHealth(): Promise { // Abort the fetch if it takes more than 500ms. const controller = new AbortController(); setTimeout(() => controller.abort(), 500);