next.js
43273a1d - [PPF] Instant validation for unstable_navigation() (#97309)

Commit
2 days ago
[PPF] Instant validation for unstable_navigation() (#97309) Adds discriminated error messages for `unstable_navigation()` used outside of Suspense. Previously we only had to discriminate two kinds of errors in each validation flow: - App Shell -- 1. link data (if it resolves in `Runtime`) or 2. dynamic data (if it resolves in `Dynamic`) - Static Shell -- 1. runtime data (if it resolves in `Runtime`) or 2. dynamic data (if it resolves in `Dynamic`) However, with `navigation()` (96908), the App Shell flow needs to distinguish three kinds: 1. link data, 2. navigation (if it resolves in `NavigationRuntime`), and 3. dynamic data. This complicates the validation code a bit, because we can no longer get away with one retry. To accommodate this, i restructured the validation code to no longer recurse as a method of retrying. We just loop over an array that defines what order we should try the stages in + what kind of hole shows up in each stage. I've also removed `hasAmbiguousErrors` and the associated logic. since we're no longer mixing Static+Runtime segments in a runtime prefetch, this is no longer relevant -- all segments used for validation use one stage, so whether or not the error is ambiguous only depends on the stage. For ease of reviewing, this is split into two commits: 1. updating the (many) places that need a new `DynamicHoleKind` in our error messages. This one has a lot of pretty mechanical changes, and was also machine-reviewed for consistency already, but the messages themselves are worth looking at (we'll also need to update docs -- leaving that for a follow-up) 2. the actual instant validation changes, i.e. using the new `DynamicHoleKind` and adding the new pass
Author
Parents
Loading