A refreshed data-layer package never reaches a running dev server

`link:polyfill` overlays the package into node_modules and keeps it current.
That is all it does. A `bun run dev` already running goes on serving what it
loaded at startup, however many times the overlay is rewritten underneath it:
node_modules is excluded by file watchers, so the change lands in the one place
nothing is looking.

The script promised the opposite -- that `bun --hot` would reload the copied
file live. That promise is now removed, and replaced by the instruction to
restart.

It cost about an hour. A defect had been fixed upstream, the overlay refreshed,
and a probe on a freshly launched server confirmed the fix 3 runs out of 3. The
same sequence by hand reproduced the defect at once. The two observations looked
irreconcilable and the hunt went to the wallet, to prior state, to timing.

The dev server had been up for six days. It predated the package rename and the
whole migration; the browser was running a different application from the one
under test. Nothing warned: a stale server looks exactly like a current one, and
the script's own header ruled out the true cause for anyone who trusted it.

The reflex is written down with the leaf: when a fix seems not to take, or when
a hand-run and an automated run disagree, check how long the server has been up
before anything else. One command, cheapest hypothesis first.
This commit is contained in:
Sylvain Duchesne
2026-08-16 22:06:52 +02:00
parent 4148df8fcb
commit ac55dc96a4
3 changed files with 44 additions and 5 deletions
+12 -4
View File
@@ -18,13 +18,20 @@
* directory holding the local polyfill's package.json + src (NO node_modules).
* 2. Asserts the single-instance invariant (same @ng-org/web realpath from Festipod and
* from the overlay) — aborts if it would break.
* 3. Watches the local polyfill src and copies each change into the overlay, so
* `bun --hot` (bun run dev) reloads the edited file live.
* 3. Watches the local polyfill src and copies each change into the overlay.
*
* ⚠️ RESTART `bun run dev` AFTER THIS SCRIPT WRITES. The overlay lives inside
* node_modules, which file watchers exclude by convention — so a running dev
* server keeps serving the polyfill it loaded at startup, however many times
* this script rewrites the files underneath it. VERIFIED the hard way: a dev
* server six days old served pre-fix code while the overlay on disk was current,
* and an hour went into hunting a defect that had already been fixed. Watching
* copies the files; it does not make anything reload them.
*
* USAGE (reactive dev):
* Terminal 1: pnpm run link:polyfill # overlays local source, then watches
* Terminal 2: bun run dev # portless festipod bun --hot src/index.ts
* Edit files under packages/polyfill/src → they land in node_modules → bun --hot reloads.
* Edit files under packages/polyfill/src → they land in node_modules → RESTART dev to pick them up.
*
* pnpm run link:polyfill --once # overlay + verify, no watch (CI / one-shot)
* Return to the committed git-installed dependency: pnpm install
@@ -85,7 +92,8 @@ if (ONCE) {
process.exit(0);
}
// 3. Watch and copy on change so `bun --hot` sees live edits.
// 3. Watch and copy on change. This keeps the overlay CURRENT; it does not make a
// running dev server notice (node_modules is outside the watcher) — restart it.
console.log(`👀 watching ${SRC_LOCAL}${SRC_TARGET} (Ctrl-C to stop)`);
watch(SRC_LOCAL, { recursive: true }, (_event, filename) => {
if (!filename) return;