Wait for hydration in external-browser-runtime hydration tests (#102060)
### What?
Fixes a flaky e2e assertion in `external-browser-runtime`. The `hydrates
<path> with bootstrap data <order> the loader` cases now wait for the
hydration marker before they run the existing hydration assertion.
### Why?
These cases open the page with `waitUntil: 'commit'` and `waitHydration:
false`, so the harness doesn't wait for hydration. They then poll
`browser.eval('!!window.__NEXT_HYDRATED')` with the default 3 s
`retry()`. `browser.eval()` reads the value right away and only then
waits for the `load` event. In webpack dev on a loaded runner, the first
read happens about 100 ms after `commit` and returns `false`. The `load`
wait then takes about 2.5–3 s. That leaves less than one 500 ms interval
in the budget, so `retry()` gives up without reading the flag a second
time.
Temporary instrumentation showed that every failing page did hydrate.
The root effect set `__NEXT_HYDRATED` about 130 ms after `load`, often
before the stale `eval` call even returned. The framework hydrates
correctly; the test was reading the flag too early.
Seen on canary in webpack dev with React 18.3.1, on two different shards
(`test dev (4/10, 18.3.1)` and `test dev (7/10, 18.3.1)`). All three
in-job tries failed both times, and a different set of cases failed on
each try.
### How?
After the loader is released, the test now waits on the raw Playwright
page for `window.__NEXT_HYDRATED === true`. It uses the same 10 s limit
as the default `next.browser()` hydration wait. All existing assertions
and the `retry()` budget are unchanged. The predicate is a function, not
a string, because the production responses in this fixture send
`Content-Security-Policy: script-src 'self'`, which blocks string
evaluation.
### Verification
Webpack dev, React 18.3.1, `IS_WEBPACK_TEST=1`, `--retries 0`, 8 vCPUs
with busy-loop CPU burners:
| CPU burners | Before | After |
|---|---:|---:|
| 16 | 10/10 runs failed (all 6 hydrate cases each run, CI assertion) |
0/10 failed |
| 8 | 0/10 failed | 0/10 failed |
| 0 | 0/5 failed | 0/5 failed |
- Turbopack production (where the deferred-loader fixture is active) and
Turbopack dev: 13/13 pass.
- `pnpm typescript`, Prettier and ESLint pass.
<!-- NEXT_JS_LLM -->
<!-- fleet 8ac454f2-8f72-45bb-a6cf-74219302bbc7 -->
Co-authored-by: vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>