From b1b741ddf7f8a24c3d2526ddbe00ccd49900d80c Mon Sep 17 00:00:00 2001 From: latenighthackathon Date: Sun, 29 Mar 2026 14:50:05 -0500 Subject: [PATCH 1/2] fix(nim): resolve host port dynamically in nimStatusByName() nimStatusByName() hardcoded port 8000 for the health check curl, but the host port is configurable via startNimContainer(). Containers started on a custom port would always report unhealthy. Use docker inspect to read the actual host port mapping from the container's NetworkSettings before probing the /v1/models endpoint. Closes #1016 --- bin/lib/nim.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/lib/nim.js b/bin/lib/nim.js index f291a0967..6164fdcb5 100644 --- a/bin/lib/nim.js +++ b/bin/lib/nim.js @@ -198,7 +198,14 @@ function nimStatusByName(name) { let healthy = false; if (state === "running") { - const health = runCapture(`curl -sf http://localhost:8000/v1/models 2>/dev/null`, { + // Resolve the host port dynamically instead of assuming 8000. + // The container always listens on 8000 internally, but the host + // mapping is configurable via startNimContainer(... port). + const hostPort = runCapture( + `docker inspect --format '{{(index (index .NetworkSettings.Ports "8000/tcp") 0).HostPort}}' ${shellQuote(name)} 2>/dev/null`, + { ignoreError: true } + ) || "8000"; + const health = runCapture(`curl -sf http://localhost:${Number(hostPort)}/v1/models 2>/dev/null`, { ignoreError: true, }); healthy = !!health; From 966f0b762e05bb9cfb9a301edb38cd5f63d2c084 Mon Sep 17 00:00:00 2001 From: latenighthackathon Date: Sun, 29 Mar 2026 15:04:39 -0500 Subject: [PATCH 2/2] fix(nim): validate host port is numeric before using in health check URL Add regex validation so unexpected docker inspect output (non-numeric text) falls back to port 8000 instead of producing a NaN URL. Addresses CodeRabbit review nitpick. --- bin/lib/nim.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/lib/nim.js b/bin/lib/nim.js index 6164fdcb5..c3b66d89a 100644 --- a/bin/lib/nim.js +++ b/bin/lib/nim.js @@ -201,11 +201,12 @@ function nimStatusByName(name) { // Resolve the host port dynamically instead of assuming 8000. // The container always listens on 8000 internally, but the host // mapping is configurable via startNimContainer(... port). - const hostPort = runCapture( + const rawHostPort = runCapture( `docker inspect --format '{{(index (index .NetworkSettings.Ports "8000/tcp") 0).HostPort}}' ${shellQuote(name)} 2>/dev/null`, { ignoreError: true } - ) || "8000"; - const health = runCapture(`curl -sf http://localhost:${Number(hostPort)}/v1/models 2>/dev/null`, { + ); + const hostPort = /^\d+$/.test(rawHostPort) ? Number(rawHostPort) : 8000; + const health = runCapture(`curl -sf http://localhost:${hostPort}/v1/models 2>/dev/null`, { ignoreError: true, }); healthy = !!health;