HP2007 (page-error) means a script threw an error while the page loaded: an
uncaught exception, an unhandled promise rejection, or an error React reported
that is not about hydration. It may or may not be related to hydration. Read the message and stack, and fix the error or confirm
it only happens in the test environment.
| Code | HP2007 |
|---|---|
| Name | page-error |
| Default severity | Warning |
| Group | Problems React reported |
| What it means | A script threw during page load. It may or may not be related to hydration. |
What HP2007 (page-error) means
hydration-proof records every error the page raises while it loads. Errors
that are React hydration messages become HP2xxx codes or evidence for a DOM
finding; everything else becomes HP2007, with the first line of the message as
the finding and the stack as evidence. console.error and console.warn calls
are not reported this way.
It is a warning by default, since the error may have nothing to do with hydration. If the same page also has HP1010 or HP2003, check whether the error comes from the branch React re-rendered.
Findings without an element are told apart by their message, so the same error on the same route has the same fingerprint in every run.
Likely causes
- Code that assumes data the page does not have in the test environment, such as an API that is not reachable or a signed-out user.
- A third-party script that fails in an automated browser.
- A real bug in code that runs on load: an effect, an event listener registered
on load, a failed
fetchwhose rejection nobody handles.
How to fix it
- Open the finding in the HTML report: the evidence has the full stack, and the timeline shows which scripts and requests ran before the error.
- Run
npx hydration-proof test --headed --workers 1 --route /accountto watch the page in a real browser window. - Fix the error. If it comes from the test environment, give the browser the
data it needs with a scenario's
mocks, or sign in with a scenario'slogin.
When the difference is intentional
If the error is known and harmless (a third-party widget that fails without a
network, for example), add an ignore.issues rule with code: "HP2007", the
route and a reason, or match its fingerprint to ignore only that error. See
ignoring findings.
Example
⚠ /account 1.3s 1 warning
HP2007 Uncaught error while loading the page
TypeError: Cannot read properties of undefined (reading 'map')