fix(deploy): serve studio static files on both harperdb 4.x and Harper 5.x - #1574
fix(deploy): serve studio static files on both harperdb 4.x and Harper 5.x#1574Devin-Holland wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the Fastify deployment template to support both Fastify 4 and Fastify 5 by dynamically selecting the appropriate version of @fastify/static (aliased as fastify4-static and fastify5-static in package.json) based on the running Fastify version. The feedback suggests adding a safety guard for fastify.version and specifying the radix in Number.parseInt to prevent potential runtime errors if the version property is undefined.
Coverage Report
File CoverageNo changed files found. |
DavidCockerill
left a comment
There was a problem hiding this comment.
Approving. Aliasing both majors is the right call for a fleet mid-upgrade, and the both-runtimes verification table in the description is solid.
Checked the things that usually bite on a dual-serve change and none of them apply: only one plugin ever registers, so there's no duplicate or stale asset and no route-precedence question, and CSP, CORS and cache policy are all unchanged.
Two non-blocking notes in threads, both about future decay rather than today — the version pick currently fails open on an unexpected fastify version, and the Renovate mute may not match npm aliases, which would let a routine dep bump reproduce the outage this fixes.
— Reviewed by DAIvid (Claude Opus 5)
|
Handoff notes (Dawson's taking the branch from here): 1. Verify Commits is failing — two commits lack Conventional Commits prefixes (on both
They're the top two commits on each branch, so a reword + 2. The Fallback if — devain (Claude Fable 5) |
7e8b8cd to
fa4610e
Compare
|
I'm flagging this as a draft, do NOT merge this until Central Manager is totally ready with v5 of Harper! |
@fastify/static@7 declares fastify 4.x only, so on a Harper 5.x CM
(fastify 5.10) plugin registration fails the fastify-plugin version
check and reply.sendFile is never decorated: GET / returns
{"error":"reply.sendFile is not a function"} and all static assets 404.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
fa4610e to
de64aa4
Compare
Problem
After upgrading the dev CM to harper-pro 5.1.23, browsing the studio root returns:
{"error":"reply.sendFile is not a function"}and every static asset 404s. Boot log shows why:
@fastify/static@7only supports fastify 4, so on Harper 5.x (fastify 5.10) the plugin registration fails andreply.sendFilenever gets decorated — while the/route itself still registers and 500s on every hit.Fix
The deploy template ships both plugin majors under npm aliases (
fastify4-static→@fastify/static@^7,fastify5-static→@fastify/static@^8) and picks the one matchingfastify.versionat registration time.Why not just bump to ^8: this same template deploys to stage/prod CMs still on harperdb 4.7.33 (fastify 4), and the CM fleet upgrades to Harper 5.x one environment at a time. A hard bump would break whichever side doesn't match, and a dev-branch-only pin would be lost on the next branch promotion. Once every CM runs Harper 5.x this collapses back to a single
@fastify/static@^8dependency (comment instatic.jsmarks it).Verification
Registered the exact template module on both runtimes and validated responses:
cache-control: public, max-age=2592000, immutable🤖 Generated with Claude Code
Follow-ups from review + dev deploy
6.0.0/undefinedboth throw.@fastify/staticdisable rule now usesmatchDepNameslisting both npm aliases, so routine dep hygiene can't re-bump the fastify-4 build out from under 4.x CMs.--no-auditon component install: first dev deploy failed inprepare— npm 11.16 exits 1 (with no error output) when a package.json using npm aliases hits audit advisories, even though the install itself completes. The @fastify/static v7/v8 lines have permanent advisories (fixes only landed in v10+), so the template'sconfig.yamlnow setsinstall.command: npm install --ignore-scripts --no-audit. Theinstallproperty is supported identically on harperdb 4.7.33 and harper-pro 5.1.23 (samecomponents/Application.tscode). Reproduced + verified in the dev CM container: aliased install with audit → exit 1, with--no-audit→ exit 0 with both aliases installed.