Repository navigation
fix(performance): report PageSpeed failures as unavailable, not score 0 - #4
Merged
Merged
Conversation
When the PageSpeed Insights API fails (rate limit, network error),
runPerformanceChecks returned score: 0 — indistinguishable from a site
that genuinely scores 0. A fresh user with no PSI_API_KEY sees
"Performance: 0", which reads as a broken tool.
- performance.js: failure path returns { available: false, score: null };
success returns { available: true }
- SiteAuditApp.jsx: the Speed category card shows a dimmed "— (n/a)" with a
tooltip instead of "0" when performance data is unavailable
- add api/__tests__/performance.test.js covering failure and success paths
- README: replace the stale "tests may fail" note (the suite runs green)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Problem
A clean-clone smoke test (fresh
git clone→npm install→npm run dev→ scan) surfaced this: without aPSI_API_KEY, the anonymous PageSpeed Insights endpoint is rate-limited and fails.runPerformanceChecksthen returnedscore: 0— indistinguishable from a site that genuinely scores 0. A new user's first scan shows Performance: 0, which reads as a broken tool. During a launch traffic spike, the shared anonymous quota makes this near-certain.Changes
api/checks/performance.js— PSI failure now returns{ available: false, score: null }; success returns{ available: true }.nullmeans "not measured";0meant "measured, terrible" — now distinct.app/src/SiteAuditApp.jsx— the Speed category card renders a dimmed— (n/a)with an explanatory tooltip instead of0when performance is unavailable. (The Performance tab already handled the error banner; the overview card did not.)api/__tests__/performance.test.js(new) — covers the rate-limit, network-error, and success paths.README.md— replaced the stale "pre-existing tests may fail" note; the full suite runs green.Verification
scores.performance: null,performance.available: false— confirmed.All existing consumers (
avgScore,generatePDF) already guard with?? 0/> 0, sonullis safe.🤖 Generated with Claude Code