dev: stop building the web app twice before boot (CL-6638) - #310
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
bun run devtook ~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.apps/webwas built twice, back-to-back —scripts/dev.ts'srequireWebBuild()ran a blocking one-shotvite build(~22s) before hub/sidecar even started, thenvite build --watch(already in theappslist) redid the identical full build (~27s) the moment it launched.isWebBuildFresh— a pure, unit-tested decision comparing the newestapps/websource 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.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), scratchHUB_DATA_DIR, and a non-default port (never touched the live :3000 stack):All three warm boots beat the ≤10s target from the ticket.
Test plan
WORKBENCH_CHECK_SINCE=origin/main bun run typecheckpassesWORKBENCH_CHECK_SINCE=origin/main bun run lintpassesscripts/dev.test.tscoversisWebBuildFresh's fresh/stale/missing-dist casesWORKBENCH_CHECK_SINCE=origin/main bun run testreports failures in 10 packages unrelated toscripts/dev.ts(sidecar-placement, chat, routines, etc.); spot-checked two of them standalone (bun testinside the package dir) and both pass cleanly — pre-existing flakiness under parallel aggregate test execution, not a regression from this change.