Describe the bug
When entering preview mode from WordPress, the initial preview page loads correctly and previewRouteHandler works as expected. However, if I navigate to any other page without exiting preview mode, the application crashes with:
TypeError: Cannot read properties of undefined (reading 'disable')
The error occurs inside Next.js internals (src/server/request/draft-mode.ts) during a query({ params }) call in a single post/page route.
This suggests that draftMode().disable() is being called somewhere without the correct this binding — which was valid in older Next.js versions but breaks in Next.js 15, where draftMode() is now asynchronous.
/api/preview/exit works correctly and exiting preview mode removes the issue.
The crash happens only when navigating in a still-active preview session.
Steps to Reproduce
- In WordPress, open any post or page.
- Click Preview.
- The preview opens correctly in the Next.js frontend (banner displayed).
- Without clicking “Exit Preview”, navigate to any other route in the Next.js site (e.g. another post, etc.).
- The page crashes with the following error:
TypeError: Cannot read properties of undefined (reading 'disable')
Screenshots, screen recording, code snippet
No response
Environment information
Device: MacBook Pro
OS: macOS Sonoma
Browser: Chrome 124, Safari 17
WordPress information
No response
Code of Conduct