Emit the static paths HMR update after updating the cache (#96019)
In dev, the server sends a `SERVER_COMPONENT_CHANGES` HMR update when
`generateStaticParams` produces a different set of static paths, so the
render picks up the new `fallbackParams` (added in #85741). It was
emitting that update before writing the new result to
`staticPathsCache`, so the refresh it triggered could read the previous,
stale result and keep rendering with the old `fallbackParams` (there are
`await`s for the prerender manifest between the two points, which widens
the window). This moves the emit to after `staticPathsCache.set`, so the
triggered refresh always observes the updated result.
This also adds the end-to-end regression test that was missing for this
behavior. Reusing the existing `use-cache-params/[slug]` fixture, it
asserts the blocking-route redbox shown when a route reads a fallback
(unknown) param outside a Suspense boundary, then adds a
`generateStaticParams` covering the requested slug and asserts the
redbox clears. Editing the page produces two refreshes: the one the edit
itself triggers, which still renders with the stale `fallbackParams`,
and the follow-up update this code emits once the new result is cached,
which renders with the fresh ones. To ensure the test only passes
because of the latter, `generateStaticParams` is given a deliberate
delay so its recompute finishes only after the edit's own refresh has
already re-rendered with the stale params.
closes NAR-496
---
<sub>Stack created with <a
href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a
href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>