Skip to content

Commit f656801

Browse files
dorlugasigalCopilot
andcommitted
fix(version): make /api/version recompute per request again
Reverts the freeze-at-startup change from 6fde764 for the route only (getVersion() and the dirty-untracked detection from that commit are preserved). In dev source checkouts the badge now updates after a git commit/pull without needing a service restart. Production npm installs are unaffected — the npm_package_version short-circuit in getVersion() returns the cached package.json value, so no extra git work happens there. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 4ee156a commit f656801

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

packages/site/src/content/docs/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ Returned when the server was started with `--no-password`.
528528

529529
#### `GET /api/version`
530530

531-
Get the server version. The value is captured once at process startup and reflects the running code (not the latest git state on disk). Restart the service to pick up a new version.
531+
Get the server version. Recomputed per request so dev source checkouts surface new commits and dirty state without a restart. Production installs short-circuit to the cached `package.json` value, so the cost is negligible.
532532

533533
**Response:**
534534

src/server/routes.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,14 @@ function setupRoutes(
163163
}
164164
});
165165

166-
// Version API — uses the version captured at server startup so dev/prod
167-
// builds stay stable for the lifetime of the process. Restart the service
168-
// to pick up a new git tag or dirty-state change.
166+
// Version API — recomputes per request so dev source checkouts surface new
167+
// commits/dirty state without a restart. In production (npm install) the
168+
// npm_package_version short-circuit in getVersion() makes this a cheap
169+
// package.json read; only source checkouts incur the git describe cost.
169170
app.get('/api/version', (_req, res) => {
170171
log.debug('Version requested');
171-
res.json({ version: config.version });
172+
const { getVersion } = require('../utils/version');
173+
res.json({ version: getVersion() });
172174
});
173175

174176
// Changelog — served from repo CHANGELOG.md (bundled with the npm package).

0 commit comments

Comments
 (0)