Deploy the application to Vercel. Here's a demo already deployed.
Click the "Enable draft mode" link
The devtools console will show the 500 error when trying to prefetch the link.
The error also appears in the Vercel logs:
⨯ Error: Invariant: expected pageData to be a string, got undefined
at r3.renderToResponseWithComponentsImpl (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:3521)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async r3.renderPageComponent (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:4780)
at async r3.renderToResponseImpl (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:5363)
at async r3.pipeImpl (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:16:17297)
at async r3.handleCatchallRenderRequest (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:36510)
at async r3.runImpl (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:16:17030)
at async r3.handleRequestImpl (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:16:16123)
at async Server.<anonymous> (/var/task/___next_launcher.cjs:25:5)
at async Server.<anonymous> (/opt/node-bridge/bridge-server-NOEMJORR.js:1:8898) {
page: '/about'
}
Error: Invariant: expected pageData to be a string, got undefined
at r3.renderToResponseWithComponentsImpl (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:3521)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async r3.renderPageComponent (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:4780)
at async r3.renderToResponseImpl (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:5363)
at async r3.pipeImpl (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:16:17297)
at async r3.handleCatchallRenderRequest (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:36510)
at async r3.runImpl (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:16:17030)
at async r3.handleRequestImpl (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:16:16123)
at async Server.<anonymous> (/var/task/___next_launcher.cjs:25:5)
at async Server.<anonymous> (/opt/node-bridge/bridge-server-NOEMJORR.js:1:8898) {
page: '/about'
}
Error: Runtime exited with error: exit status 1
Runtime.ExitError
Current vs. Expected behavior
Link prefetch should not happen when in draft mode.
Provide environment information
This happens when the app is deployed in Vercel. It does not happen in localhost.
Tested in Chrome and Safari.
Which area(s) are affected? (Select all that apply)
Experiencing the same bug. It only happens with draftMode. I was unable to pinpoint the exact cause until I found this thread! It is definitely draftMode related.
Link to the code that reproduces this issue
https://github.com/monogram-labs/nextjs-prefetch-draft-mode
To Reproduce
Current vs. Expected behavior
Link prefetch should not happen when in draft mode.
Provide environment information
Which area(s) are affected? (Select all that apply)
App Router, Routing (next/router, next/navigation, next/link)
Which stage(s) are affected? (Select all that apply)
Vercel (Deployed)
Additional context
This happens only when deployed to Vercel not in localhost.