Skip to content

dev: stop building the web app twice before boot (CL-6638) - #310

Merged
TheGreatAxios merged 1 commit into
mainfrom
cl-6638-fast-boot
Aug 22, 2026
Merged

dev: stop building the web app twice before boot (CL-6638)#310
TheGreatAxios merged 1 commit into
mainfrom
cl-6638-fast-boot

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Contributor

Summary

  • CL-6638: bun run dev took ~90s before the sidecar registered and the app served. Profiled via the timestamped boot log and posted the timeline as a comment on the ticket before touching code.
  • Root cause: apps/web was built twice, back-to-back — scripts/dev.ts's requireWebBuild() ran a blocking one-shot vite build (~22s) before hub/sidecar even started, then vite build --watch (already in the apps list) redid the identical full build (~27s) the moment it launched.
  • Fix: drop the redundant one-shot build; start hub, sidecar, and the web watcher concurrently. Added isWebBuildFresh — a pure, unit-tested decision comparing the newest apps/web source mtime against the dist bundle's mtime — so a warm boot with nothing changed defers spawning the vite watcher until a source file actually changes, instead of paying for a rebuild whose output would be byte-identical.
  • CL-6627's port-in-use guard (requireHubPortFree) is untouched and still runs before anything else — verified manually that it still refuses to start against an occupied port.

Measurements

On a scratch worktree with a scratch DB (wb_boot_test), scratch HUB_DATA_DIR, and a non-default port (never touched the live :3000 stack):

  • Cold boot (fresh DB, 86 migrations, no dist yet): sidecar registered at 70.7s — dominated by first-time migrations; the web build (33.1s) now runs concurrently and off the critical path instead of serially before it.
  • Warm boot 1: 7.74s
  • Warm boot 2: 6.93s
  • Warm boot 3: 7.85s

All three warm boots beat the ≤10s target from the ticket.

Test plan

  • WORKBENCH_CHECK_SINCE=origin/main bun run typecheck passes
  • WORKBENCH_CHECK_SINCE=origin/main bun run lint passes
  • scripts/dev.test.ts covers isWebBuildFresh's fresh/stale/missing-dist cases
  • Aggregate WORKBENCH_CHECK_SINCE=origin/main bun run test reports failures in 10 packages unrelated to scripts/dev.ts (sidecar-placement, chat, routines, etc.); spot-checked two of them standalone (bun test inside the package dir) and both pass cleanly — pre-existing flakiness under parallel aggregate test execution, not a regression from this change.
  • Manually verified the port-in-use failure path (CL-6627) still refuses to start

scripts/dev.ts ran a blocking one-shot vite build before hub and
sidecar were even started, then vite build --watch redid the exact
same full build as soon as it launched — about 22s + 27s of pure
duplication, and none of it overlapped with hub/sidecar startup.

Drop the one-shot build and start hub, sidecar, and the web watcher
concurrently. Add a source-mtime-vs-dist freshness check
(isWebBuildFresh) so a warm boot with nothing changed under apps/web
defers starting the watcher until a source file actually changes,
instead of paying for another full build whose output would be
byte-identical. CL-6627's port-in-use guard is untouched.
@TheGreatAxios
TheGreatAxios merged commit 30eb69e into main Aug 22, 2026
5 checks passed
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.

1 participant