next.js
f5e54c06 - Forward invalid dynamic usage errors on client-side navigations (#93184)

Commit
161 days ago
Forward invalid dynamic usage errors on client-side navigations (#93184) In dev mode, the static shell validation only runs during the initial page load and HMR refreshes, not during client-side navigations. During a client-side navigation an invalid dynamic usage error — for example a `'use cache'` fill timeout, or a request API like `cookies()` called inside a `'use cache'` scope — does still reach the browser via the errored `'use cache'` stream. But when the cache invocation is wrapped in a user-space `try`/`catch`, the error is caught and swallowed in user code, and because the static shell validation isn't running to surface it separately, the error is then neither sent to the browser nor logged to the terminal. When we skip the validation, we now wait for the full render stream to finish and then, if an error was recorded during the render, send it to the browser and log it to the terminal. Waiting for the stream to finish mirrors what the static shell validation already does, and ensures we also catch errors from `'use cache'` invocations that only run in the dynamic stage.
Author
Parents
Loading