Performance & Testing
Tracking page-load and flow-completion performance, plus an ongoing testing roadmap. Started from the 2026-05-11 finding that a new user's first login took ~50–60 seconds end-to-end.
Sections
Observed problem (2026-05-11)
Test user completed the public sign-up form (steps 1→3), clicked "Log In & View Checklist," entered phone + verification code:
- Delay 1: ~20–30s between clicking Verify & Sign In and seeing the Profile Completion form. Button stuck on "Please wait…".
- Delay 2: ~20–30s between clicking Complete Profile and arriving at the Checklist page. Same silent wait.
Root cause — Delay 1
onAuthStateChanged ran a 4-way decision tree with up to 7 sequential Firestore round-trips while the user waited:
- 1×
getDoc(users/<uid>)(Check A) - 4× sequential
getDocsinfindExistingProfile()— 3 phone-format variants + 1 email - 2× sequential
getDocsinfindInvite()— phone then email
On a mobile network with 500–2000ms per round-trip, this adds up.
Root cause — Delay 2
The Profile Completion handler did 8+ sequential awaits:
- 1×
getDoc(read invite) - 1×
updateProfile(Firebase Auth displayName) - 1×
setDoc(users/<uid>) - 1×
updateDoc(invites/<id>)(mark accepted) - 1×
addDoc(family_members)(self record) - N×
addDoc(family_members)per trailman - M×
addDoc(family_members)per other family member - M'×
setDoc(invites/...)for downstream family invites
For a typical "1 trailman + 1 spouse with email" signup, that's ~8 sequential network calls before navigation. Plus the new page (/dashboard/checklist.html) does its own auth + Firestore queries on first load.
Fixes shipped 2026-05-11
Promise.all. The updateProfile call for the Firebase Auth displayName joins the same batch. Drops 8+ sequential round-trips to one round-trip window.File:
login.js (profile-completion submit handler).File:
login.js (profile-completion submit handler, end of signupData block).findExistingProfile() and findInvite() now run all candidate queries via Promise.all instead of sequentially. For a brand-new user where every lookup returns empty, this drops 6 round-trips to 1.File:
login.js.Future improvements
sendFamilyWelcomeSms, sendInviteSms, and signupNotify all suffer cold-start penalties (5–15s) when idle. A scheduled "ping every 5 min during business hours" trigger keeps them warm. Or use onSchedule('every 5 minutes') with a tiny no-op invocation per function.sms_queue Firestore collection that triggers a Cloud Function via Firestore-trigger. Client returns immediately; sending happens in the background. Same pattern for any other slow Cloud Function calls. Cleaner than ad-hoc fire-and-forget.completeProfile). Client makes one call with the form data; server does all the Firestore writes in a batch + creates downstream invites + fires SMS. Cleaner error handling + one network round-trip from the user's perspective.findExistingProfile.findExistingProfile checks 3 phone formats because legacy data may have +1-prefixed or E.164 stored values. A one-off cleanup tool ("Normalize Phone Numbers" — already exists in admin-tools) should make this unnecessary. After running it, drop the +1 / E.164 checks and keep only the 10-digit lookup./dashboard/checklist.html, that page does its own auth check + family_members query. The browser could pre-warm the connection or pre-fetch the page during the Promise.all wait so the navigation feels instant. Service-worker territory; low priority.Testing roadmap
Each fix needs a before/after measurement. Use the same test-account flow each time so numbers are comparable.
invite-actions.js, not login.js. Confirm it's still sequential there (or apply the same parallelization later). Time the click→done transition.Performance targets
What "good" looks like for the most user-facing flows:
| Flow | Target | Acceptable | Investigate if > |
|---|---|---|---|
| Verify code → Profile Completion shown | ≤2s | ≤5s | 10s |
| Complete Profile → Checklist loaded | ≤3s | ≤6s | 12s |
| Dashboard initial load (logged in) | ≤1.5s | ≤3s | 6s |
| Pay Dues click → Stripe Checkout open | ≤2s | ≤4s | 8s |
| Admin Convert click → completion | ≤2s | ≤5s | 10s |
| People page load (100+ records) | ≤2s | ≤4s | 8s |
Captured 2026-05-11 in response to a real user-flow latency issue.