Fix draft mode invariant (#62121)
### What? In today's implementation, requests that don't end in `.rsc` are getting the data request query. We need to remove this toggle to prevent them from 500'ing. ### Why? The invariant triggered was:212553958c/packages/next/src/server/base-server.ts (L2838-L2842)
Crawling up the code, the conditional:212553958c/packages/next/src/server/base-server.ts (L2815)
must be `true`. The variable `isDataReq` is set here:212553958c/packages/next/src/server/base-server.ts (L1833-L1839)
This conditional expression is a bit complex, but it simplifies down to: - `isDataReq` is `true` when (TODO) - `isDataReq` is `false` when (TODO) ### How? Closes NEXT-2341 Fixes #61377 Tested manually by: - Building and packaging this branch locally - Deploying tarball and then depending on it as the Next.js version for an example app similar to the one reported by #61377 - Inspecting console for 500 errors. --------- Co-authored-by: JJ Kasper <jj@jjsweb.site> Co-authored-by: Zack Tanner <zacktanner@gmail.com>
This commit is contained in:
parent
79b7cb5f07
commit
eea4e6079f
1 changed files with 5 additions and 1 deletions
|
@ -2831,7 +2831,11 @@ export default abstract class Server<ServerOptions extends Options = Options> {
|
|||
res.setHeader(NEXT_DID_POSTPONE_HEADER, '1')
|
||||
}
|
||||
|
||||
if (isDataReq) {
|
||||
// we don't go through this block when preview mode is true
|
||||
// as preview mode is a dynamic request (bypasses cache) and doesn't
|
||||
// generate both HTML and payloads in the same request so continue to just
|
||||
// return the generated payload
|
||||
if (isDataReq && !isPreviewMode) {
|
||||
// If this is a dynamic RSC request, then stream the response.
|
||||
if (isDynamicRSCRequest) {
|
||||
if (cachedData.pageData) {
|
||||
|
|
Loading…
Reference in a new issue