Fix hybrid Pages/App Router not-found rendering with adapters (#96392)
## Summary When Pages Router and App Router routes coexist, a Pages Router route that returns `notFound` will internally hand rendering to the App Router not-found page. Next.js [prefers the App Router `/_not-found` entry for 404 responses](https://github.com/vercel/next.js/blob/5f5e4773bbb54f19697063ea093e8d89ca7d081a/packages/next/src/server/base-server.ts#L2965-L2980) before falling back to a Pages Router `/404` page. When deployed via an adapter, this means it would have attempted to resume the Pages entry, which wouldn't contain the relevant prerendered shell or postponed state. If the not-found page suspends, its response cannot be resumed using the metadata associated with the Pages Router output. For adapter requests, this marks the handoff with an empty postponed state. This uses the existing resume protocol to perform a complete, non-cacheable dynamic render. `next start` continues to use the normal PPR path, where it can load and resume the App Router not-found output directly. This trades PPR shell reuse for correctness only during this cross-router not-found handoff. Longer term, adapters should have an explicit contract for cross-output handoffs so they can select and resume the App Router not-found output normally, without necessarily declaring the pages router output PPR-capable. The change also documents the empty postponed-state contract and adds deployment regression coverage. ## Verification - Added an end-to-end test that verifies a Pages Router `notFound` response includes the dynamic App Router not-found content when deployed. - `pnpm testheadless test/e2e/app-dir/pages-router-app-not-found` - `pnpm --filter=next types` <!-- NEXT_JS_LLM -->
Showing
Please
register
or
sign in
to comment