Skip to content

feat(dev): speed up and add a live dashboard to local stack startup#20688

Open
vbudhram wants to merge 1 commit into
mainfrom
faster-stack
Open

feat(dev): speed up and add a live dashboard to local stack startup#20688
vbudhram wants to merge 1 commit into
mainfrom
faster-stack

Conversation

@vbudhram

@vbudhram vbudhram commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Because

  • A cold yarn start mza ran full production builds of the entire @fxa/* library graph, which the dev servers resolve from src anyway, so most of that build work was wasted.
  • It streamed raw nx/pm2/build output, so it was hard to tell which services were up, and failures were easy to miss in the noise.

This pull request

  • Adds a build-dev fast path via separate start-dev / restart-dev nx targets (nx.json, per-package package.json). yarn start mza / yarn restart mza use them; full yarn start / yarn restart and CI keep build and stay race-free.
  • Adds _scripts/start-dashboard.js (+ start-dashboard.test.js): an in-place per-service dashboard (nx command, live activity line, phase, ready time). TTY-only; FXA_START_PLAIN=1 / non-TTY fall back to streaming. Raw output always lands in artifacts/nx-start-dev.log, and every failure points to where to look.
  • Adds _scripts/start-mza.sh: quiets pm2 infra/launch/table noise and reports total startup time.
  • Hardens startup: docker preflight, labeled URL readiness checks, redis gate (REDIS_PASSWORD), dynamic db-patcher count, parallel fxa-shared ESM/CJS compile, and a check-build-dev-coverage.sh guard.

Speed improvements

Metric Before After
yarn start mza build graph 143 tasks (full @fxa/* build) 24 tasks, 0 prod lib builds
yarn restart mza lib builds 99 3
yarn restart mza wall (warm) ~174s ~90s

@fxa/* libs resolve from src at dev runtime, so build-dev skips them. Full yarn start / yarn restart / CI graphs are unchanged.

Issue that this pull request solves

N/A — local dev-tooling improvement (no Jira ticket).

Checklist

Put an x in the boxes that apply

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).
  • I have manually reviewed all AI generated code.

Other information

How to test:

  1. yarn start mza (TTY) → expect the compact infra summary + live dashboard, then ✅ Stack ready in Ns.
  2. Re-run yarn restart mza → reloads via build-dev (~3 build tasks), not the full lib build.
  3. FXA_START_PLAIN=1 yarn start mza → falls back to plain nx/pm2 streaming.

Output

mac:fxa-agent vijaybudham$ yarn start mza
nps is executing `start.mza` : _scripts/start-mza.sh tag:type:core,tag:type:demo
Starting infrastructure…
  ✅ docker network fxa
  ✅ infrastructure started: mysql redis sns firestore sync jaeger otel-collector cloud-tasks-emulator cirrus 
waiting for containers to start
⏳ Waiting for goaws (SNS) (http://localhost:4100/health, expect HTTP 200)...
✅ goaws (SNS) responded in 2s
⏳ Waiting for firebase emulator (http://localhost:9299/api/config, expect HTTP 200)...
✅ firebase emulator responded in 4s

Checking for redis...
✅ redis responded in 1s
waiting for DB patches

Checking for DB patches...
⏳ Waiting for DB patches to complete...
📋 Patch Summary:
  ✅ Successfully patched fxa to 193
  ✅ Successfully patched fxa_oauth to 37
  ✅ Successfully patched fxa_profile to 4
  ✅ Successfully patched pushbox to 2
✅ DB patches applied successfully

Checking Node version compatibility...
✅ Node version is compatible (v24.15.0, required 24.15.0)
Mozilla Accounts services — starting                  1:27
nx run-many -t start-dev --projects=tag:type:core,tag:type:demo
──────────────────────────────────────────────────────
  ✔  fxa-auth-server      ready   :9000  80s
  ✔  fxa-profile-server   ready   :1111  24s
  ✔  fxa-content-server   ready   :3030  87s
  ✔  fxa-settings         ready   :3000  62s
  ✔  123done              ready   :8080  42s
──────────────────────────────────────────────────────
  5/5 ready   deps ✔
  ▸ nx: all tasks complete
  logs ▸ artifacts/nx-start-dev.log

  All services responded.  💡 'yarn ports' lists every port.

✅ Stack ready in 109s. Run 'yarn stop' to stop all the servers.

Comment thread _scripts/start-dashboard.js Dismissed
@vbudhram vbudhram force-pushed the faster-stack branch 4 times, most recently from 8008bd6 to e552f0b Compare June 4, 2026 15:42
@vbudhram vbudhram marked this pull request as ready for review June 4, 2026 15:44
Copilot AI review requested due to automatic review settings June 4, 2026 15:44
@vbudhram vbudhram requested a review from a team as a code owner June 4, 2026 15:44
persist-credentials: false
- name: Set up Node
# .nvmrc ships in the FxA repo, checked out into fxa-code/ just above
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was failing for me in CI and reordering fixed it. Seems like we should use the nvmrc in FxA reitehr way.

Comment thread _dev/pm2/start.sh
exit 1
fi

# On an interactive TTY (the same gate the start dashboard uses), replace pm2's

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't have to add this, but watching all the pm2 and nx builds go by just seemed excessive. Now there is a simple live dashboard as the services come up. You can still see logs with FXA_START_PLAIN=1

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the local yarn start mza / yarn restart mza developer workflow by introducing a “dev-fast” Nx path (build-dev / start-dev / restart-dev) that avoids unnecessary full production library builds, and by adding a TTY-only live startup dashboard that summarizes per-service readiness while still capturing full raw output to artifacts/.

Changes:

  • Add Nx build-dev / start-dev / restart-dev target defaults and wire per-package build-dev/start-dev/restart-dev scripts so mza can take a faster startup path.
  • Introduce a TTY dashboard (_scripts/start-dashboard.js) for start-dev that renders per-service status and writes full Nx output to artifacts/nx-start-dev.log.
  • Harden startup reliability (Docker preflight, labeled URL checks, Redis gate, dynamic db-patcher expected count) and adjust l10n GitHub Actions node setup to use the checked-out repo’s .nvmrc.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/fxa-shared/scripts/build-ts-parallel.sh Parallelizes ESM/CJS TypeScript builds for fxa-shared to reduce critical-path startup time.
packages/fxa-shared/package.json Switches build-ts to the parallel script; adds build-dev/start-dev/restart-dev.
packages/fxa-settings/package.json Adds build-dev; adds start-dev/restart-dev; improves readiness check labeling.
packages/fxa-react/package.json Adds build-dev plus start-dev/restart-dev aliases.
packages/fxa-profile-server/package.json Adds build-dev and start-dev/restart-dev; improves readiness check labeling.
packages/fxa-customs-server/package.json Adds start-dev/restart-dev aliases.
packages/fxa-content-server/package.json Adds build-dev, readiness labeling, and implicitDependencies for build-dev graph correctness.
packages/fxa-auth-server/package.json Adds build-dev, start-dev/restart-dev, and Nx start-dev dependency tweaks (incl. gen-keys).
packages/fxa-auth-client/package.json Adds build-dev script for dev-fast graph compatibility.
packages/123done/package.json Adds start-dev/restart-dev aliases for dev-fast orchestration.
package-scripts.js Routes start mza through _scripts/start-mza.sh and uses restart-dev for mza restarts.
nx.json Adds build-dev, start-dev, and restart-dev target defaults/outputs for dev-fast execution.
libs/vendored/crypto-relier/project.json Adds build-dev target so dist-loaded code is built in the dev-fast path.
libs/shared/l10n/project.json Adds build-dev target for dev-fast coverage.
.github/workflows/l10n-gettext-extract.yml Ensures setup-node reads .nvmrc from the checked-out FxA repo path.
_scripts/start-mza.sh New wrapper for mza startup: preflight + infra + dev-fast services + quiet sync restart + total time.
_scripts/start-dashboard.test.js Adds pure-logic tests for dashboard line parsing/state transitions.
_scripts/start-dashboard.js Implements the live TTY startup dashboard and log capture for start-dev.
_scripts/pm2-all.sh Adds dashboard entrypoint for start-dev, streams Nx output to logs, and improves readiness banner checks.
_scripts/check-url.sh Enhances readiness polling output with labels/heartbeat and improved messaging.
_scripts/check-redis.sh Adds a redis readiness gate (non-fatal) to reduce cold-start connection noise.
_scripts/check-pre-launch.sh Avoids blocking prompts in non-TTY contexts when Nx cache is large.
_scripts/check-db-patcher.sh Derives expected db-patcher count dynamically from migrations layout.
_scripts/check-build-dev-coverage.sh Adds a guard to ensure dist-loaded libs in mza scope have a build-dev target.
_dev/pm2/start.sh Adds Docker daemon preflight, quiet infra startup path, labeled URL checks, and redis/db-patcher gating.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread _scripts/check-url.sh Outdated
Comment on lines +15 to +16
for i in $(seq 1 "$RETRY"); do
if [ "$(curl -s -o /dev/null -w "%{http_code}" "http://$TARGET")" == "$EXPECTED" ]; then
Comment on lines +27 to +31
{ project: 'fxa-auth-server', label: 'fxa-auth-server', url: 'http://localhost:9000/__heartbeat__', pm2: 'auth' },
{ project: 'fxa-profile-server', label: 'fxa-profile-server', url: 'http://localhost:1111/__heartbeat__', pm2: 'profile' },
{ project: 'fxa-content-server', label: 'fxa-content-server', url: 'http://localhost:3030', pm2: 'content' },
{ project: 'fxa-settings', label: 'fxa-settings', url: 'http://localhost:3000/settings/static/js/bundle.js', pm2: 'settings-react' },
{ project: '123done', label: '123done', url: 'http://localhost:8080', pm2: '123done' },
Comment on lines +52 to +53
if (j.targets && j.targets['build-dev']) ok=true;
if (j.scripts && j.scripts['build-dev']) ok=true;
#!/usr/bin/env node
'use strict';

// Live, in-place startup dashboard for `yarn start mza` (the start-dev fast

@vbudhram vbudhram Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI helped to build this live dashboard out. TLDR is there is a state machine to track the services startup state, rendering live output from nx and pm2 and service health polling

Since this is only on yarn start mza and a developer only improvement I think its probably ok.

"command": "echo Build complete"
}
},
"build-dev": {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This nx command is the stripped down version of build, skips compiling since dev mode builds from source anyways.

Because:
 - Local stack startup (yarn start / yarn start mza) was slow and gave
   little feedback about what was happening during the boot sequence.

This commit:
 - Speeds up the local stack startup and adds a live dashboard.
 - Shows a spinner during the quiet sync restart in yarn start mza.
 - Fixes the l10n-gettext-extract workflow's Node setup: the FxA repo is
   checked out into fxa-code/, so the root .nvmrc setup-node looked for
   was never present. Reorders setup-node after the checkout and points
   node-version-file at fxa-code/.nvmrc, keeping a single version source.
 - Bounds check-url.sh curl with connect/max timeouts so a stalled
   connection can't hang the readiness loop.
 - Polls fxa-content-server's bundle path so the dashboard can't report
   ready before webpack emits the bundle.
 - Recognizes build-dev declared under package.json nx.targets in the
   build-dev coverage guard.
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.

3 participants