HTTP status codes are incorrect when streaming is blocked and layout.js is present.
The issue involves incorrect HTTP status codes (200 instead of 404 or 307) when `generateMetadata()` blocks streaming and a `layout.js` file is present. The expected behavior is to return the correct status codes before streaming starts. The problem requires understanding Next.js's streaming and metadata handling.
https://github.com/p00000001/error-status-codes-bug
Throw notFound() page link and monitor the http status response in DevToolsThrow redirect() page link and monitor the http status response in DevToolsgenerateMetadata() became async to support metadata streaming by default: https://nextjs.org/docs/app/api-reference/functions/generate-metadata#streaming-metadatanotFound() and redirect() from generateMetadata() will return a 200 response code and use client-side JavaScript to handle functionality.next.config.js permits a property htmlLimitedBots to block streaming until generateMetadata() is resolved.notFound() or redirect() from generateMetadata() should return a 404 and 307 status code respectively as streaming has not started.layout.js in the root directory. However, when there is a layout.js file present, the status code is always 200 - the same behaviour as when streaming is active.generateMetadata() is blocking streaming, I would have expected the same status code behaviour regardless of the presence of layout.js, as the desired status code is already known before streaming has started?htmlLimitedBots: /.+/ so that all user agents get blocked generateMetadata().Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!