Hydration Proof

Search documentation

Find a page or section

HP2007: Uncaught error while loading the page

HP2007 (page error): a script threw an uncaught error while the page loaded. It may or may not be related to hydration. How to read it, fix it or ignore it.

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.

CodeHP2007
Namepage-error
Default severityWarning
GroupProblems React reported
What it meansA 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 fetch whose rejection nobody handles.

How to fix it

  1. 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.
  2. Run npx hydration-proof test --headed --workers 1 --route /account to watch the page in a real browser window.
  3. 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's login.

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')