Skip to content

Commit 4002f4b

Browse files
Ethan-Arrowoodijjkztanner
committed
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: https://github.com/vercel/next.js/blob/212553958c671ea1f71d96fbc97ea4b9e5019bf3/packages/next/src/server/base-server.ts#L2838-L2842 Crawling up the code, the conditional: https://github.com/vercel/next.js/blob/212553958c671ea1f71d96fbc97ea4b9e5019bf3/packages/next/src/server/base-server.ts#L2815 must be `true`. The variable `isDataReq` is set here: https://github.com/vercel/next.js/blob/212553958c671ea1f71d96fbc97ea4b9e5019bf3/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 <[email protected]> Co-authored-by: Zack Tanner <[email protected]>
1 parent 7dbf6f8 commit 4002f4b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: packages/next/src/server/base-server.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -2810,7 +2810,11 @@ export default abstract class Server<ServerOptions extends Options = Options> {
28102810
res.setHeader(NEXT_DID_POSTPONE_HEADER, '1')
28112811
}
28122812

2813-
if (isDataReq) {
2813+
// we don't go through this block when preview mode is true
2814+
// as preview mode is a dynamic request (bypasses cache) and doesn't
2815+
// generate both HTML and payloads in the same request so continue to just
2816+
// return the generated payload
2817+
if (isDataReq && !isPreviewMode) {
28142818
// If this is a dynamic RSC request, then stream the response.
28152819
if (isDynamicRSCRequest) {
28162820
if (cachedData.pageData) {

0 commit comments

Comments
 (0)