Skip to content

fix(healthz): read version from package.json (not npm_package_version)#134

Merged
CryptoJones merged 1 commit into
masterfrom
fix/healthz-version-from-package-json
May 19, 2026
Merged

fix(healthz): read version from package.json (not npm_package_version)#134
CryptoJones merged 1 commit into
masterfrom
fix/healthz-version-from-package-json

Conversation

@CryptoJones
Copy link
Copy Markdown
Owner

Closes #133.

Summary

process.env.npm_package_version is only set when the process is launched via an npm script. The repo Dockerfile (line 80) launches via CMD ["node", "server.js"] — no npm wrapper — so in production deployments /healthz always returned version: "unknown". Operators verifying a rolling deploy ("is the new pod at v1.2.3 yet?") got no signal.

Read version from package.json once at module load. Wrapped in try/catch so a broken install can't take /healthz down — the endpoint is operationally critical and must come up even when the manifest is missing.

Test plan

  • npm run lint — clean
  • npm test — 492 passed (was 491 + new regression test), 15 skipped
  • New test asserts body.version === require('../../package.json').version and that the 'unknown' fallback never appears on a healthy install

Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/

`process.env.npm_package_version` is only set when the process is
launched via an npm script. The repo Dockerfile (line 80)
`CMD ["node", "server.js"]` — no npm wrapper — so in production
deployments `/healthz` always returned `version: "unknown"`.
Operators trying to verify a rolling deploy ("is the new pod at
v1.2.3 yet?") got no signal.

Read `version` from `package.json` once at module load. The lookup
is wrapped in try/catch so a broken install can't take /healthz
down — the endpoint is operationally critical and must come up
even when the manifest is missing.

New test asserts `body.version === require('../../package.json').version`
and that the fallback `'unknown'` string never appears on a healthy
install.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@CryptoJones CryptoJones merged commit 48d8801 into master May 19, 2026
3 checks passed
@CryptoJones CryptoJones deleted the fix/healthz-version-from-package-json branch May 19, 2026 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

healthz: version always reports 'unknown' in production (Dockerfile launches node directly, not npm)

1 participant