-
Notifications
You must be signed in to change notification settings - Fork 27.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft Mode isEnabled is always false on the Edge Runtime #52080
Comments
It also seems like draft mode cannot be enabled from an edge Route Handler. Navigating to /api/draft results in an error: "Error: Invariant: previewProps missing previewModeId this should never happen" // /api/draft/route.ts
import { draftMode } from 'next/headers'
export const runtime = 'edge'
export async function GET() {
draftMode().enable()
return new Response('Draft mode is enabled')
} Additionally, if |
There is a e2e test suite that suggests it should work, but I don't think any of those tests are actually testing pages with The tests are just testing the standard node implementation. |
Any update on this? Experiencing this issue as well. |
Hoping this can make its way up the priority list for the next release. we sadly find ourselves having to opt-out of edge runtime on the majority of our projects/routes because of this issue. |
I ended up using |
We're seeing either the same, or a similar issue when running in development. In development mode, if no prerender manifest exists on the server instance it'll create a new one, which results in a new id for __prerender_bypass as expected. Maybe the prerender manifest should be written to disk in development-mode as well? Edit: It's worth mentioning this only happened after upgrading from 13.x to 14.x. I don't know which version in between started "experimenting" with an IPC bridge, and workers, but that's definitely where it broke for us. Edit 2: Another note to add, is that previously when an invalid __prerender_bypass was supplied, our server would simply just fail with a 5xx status code, now it simply removes the cookie silently. |
Is there an update on this? Upgraded to 14.2 and still having the same issue in development? |
- Not necessary because the one cannot exist without the other - Enables checking for previewParams in middleware (vercel/next.js#52080)
Required to allow checking for previewParams in middleware (vercel/next.js#52080). --------- Co-authored-by: Johannes Obermair <48853629+johnnyomair@users.noreply.github.com>
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Chnage the way of preview props injection to edge runtime, directly read from env vars of preview props instead of writing to and reading from prerender manifest.js Previously we're trying to make these preview props values become deterministic that we can replace in edge deployment pipeline in #64521 But the way of serializing process env vars in edge runtime is not correct. They'll remain as string "process.env.xxx" in the manifest and also after consumed. This PR fixes that behavior, instead of writing it into manifest, alwyas consuming from process.env.var directly. I created a shared util to access the preview props of edge runtime across all the templates. On draft provider side, we still need to handle dev mode case when preview id is `development-id`, but we already have the cookie, it cannot be aligned with the preview id. So we do a fallback check for dev mode if the cookie is present and preview id is `development-id` then we still treat it as draft mode is enabled. Fixes #52080 Fixes #67075 Closes NEXT-3541
Chnage the way of preview props injection to edge runtime, directly read from env vars of preview props instead of writing to and reading from prerender manifest.js Previously we're trying to make these preview props values become deterministic that we can replace in edge deployment pipeline in #64521 But the way of serializing process env vars in edge runtime is not correct. They'll remain as string "process.env.xxx" in the manifest and also after consumed. This PR fixes that behavior, instead of writing it into manifest, alwyas consuming from process.env.var directly. I created a shared util to access the preview props of edge runtime across all the templates. On draft provider side, we still need to handle dev mode case when preview id is `development-id`, but we already have the cookie, it cannot be aligned with the preview id. So we do a fallback check for dev mode if the cookie is present and preview id is `development-id` then we still treat it as draft mode is enabled. Fixes #52080 Fixes #67075 Closes NEXT-3541
Chnage the way of preview props injection to edge runtime, directly read from env vars of preview props instead of writing to and reading from prerender manifest.js Previously we're trying to make these preview props values become deterministic that we can replace in edge deployment pipeline in #64521 But the way of serializing process env vars in edge runtime is not correct. They'll remain as string "process.env.xxx" in the manifest and also after consumed. This PR fixes that behavior, instead of writing it into manifest, alwyas consuming from process.env.var directly. I created a shared util to access the preview props of edge runtime across all the templates. On draft provider side, we still need to handle dev mode case when preview id is `development-id`, but we already have the cookie, it cannot be aligned with the preview id. So we do a fallback check for dev mode if the cookie is present and preview id is `development-id` then we still treat it as draft mode is enabled. Fixes #52080 Fixes #67075 Closes NEXT-3541
Chnage the way of preview props injection to edge runtime, directly read from env vars of preview props instead of writing to and reading from prerender manifest.js Previously we're trying to make these preview props values become deterministic that we can replace in edge deployment pipeline in #64521 But the way of serializing process env vars in edge runtime is not correct. They'll remain as string "process.env.xxx" in the manifest and also after consumed. This PR fixes that behavior, instead of writing it into manifest, alwyas consuming from process.env.var directly. I created a shared util to access the preview props of edge runtime across all the templates. On draft provider side, we still need to handle dev mode case when preview id is `development-id`, but we already have the cookie, it cannot be aligned with the preview id. So we do a fallback check for dev mode if the cookie is present and preview id is `development-id` then we still treat it as draft mode is enabled. Fixes #52080 Fixes #67075 Closes NEXT-3541
Chnage the way of preview props injection to edge runtime, directly read from env vars of preview props instead of writing to and reading from prerender manifest.js Previously we're trying to make these preview props values become deterministic that we can replace in edge deployment pipeline in #64521 But the way of serializing process env vars in edge runtime is not correct. They'll remain as string "process.env.xxx" in the manifest and also after consumed. This PR fixes that behavior, instead of writing it into manifest, alwyas consuming from process.env.var directly. I created a shared util to access the preview props of edge runtime across all the templates. On draft provider side, we still need to handle dev mode case when preview id is `development-id`, but we already have the cookie, it cannot be aligned with the preview id. So we do a fallback check for dev mode if the cookie is present and preview id is `development-id` then we still treat it as draft mode is enabled. Fixes #52080 Fixes #67075 Closes NEXT-3541
Chnage the way of preview props injection to edge runtime, directly read from env vars of preview props instead of writing to and reading from prerender manifest.js Previously we're trying to make these preview props values become deterministic that we can replace in edge deployment pipeline in #64521 But the way of serializing process env vars in edge runtime is not correct. They'll remain as string "process.env.xxx" in the manifest and also after consumed. This PR fixes that behavior, instead of writing it into manifest, alwyas consuming from process.env.var directly. I created a shared util to access the preview props of edge runtime across all the templates. On draft provider side, we still need to handle dev mode case when preview id is `development-id`, but we already have the cookie, it cannot be aligned with the preview id. So we do a fallback check for dev mode if the cookie is present and preview id is `development-id` then we still treat it as draft mode is enabled. Fixes #52080 Fixes #67075 Closes NEXT-3541
Chnage the way of preview props injection to edge runtime, directly read from env vars of preview props instead of writing to and reading from prerender manifest.js Previously we're trying to make these preview props values become deterministic that we can replace in edge deployment pipeline in #64521 But the way of serializing process env vars in edge runtime is not correct. They'll remain as string "process.env.xxx" in the manifest and also after consumed. This PR fixes that behavior, instead of writing it into manifest, alwyas consuming from process.env.var directly. I created a shared util to access the preview props of edge runtime across all the templates. On draft provider side, we still need to handle dev mode case when preview id is `development-id`, but we already have the cookie, it cannot be aligned with the preview id. So we do a fallback check for dev mode if the cookie is present and preview id is `development-id` then we still treat it as draft mode is enabled. Fixes #52080 Fixes #67075 Closes NEXT-3541
Chnage the way of preview props injection to edge runtime, directly read from env vars of preview props instead of writing to and reading from prerender manifest.js Previously we're trying to make these preview props values become deterministic that we can replace in edge deployment pipeline in #64521 But the way of serializing process env vars in edge runtime is not correct. They'll remain as string "process.env.xxx" in the manifest and also after consumed. This PR fixes that behavior, instead of writing it into manifest, alwyas consuming from process.env.var directly. I created a shared util to access the preview props of edge runtime across all the templates. On draft provider side, we still need to handle dev mode case when preview id is `development-id`, but we already have the cookie, it cannot be aligned with the preview id. So we do a fallback check for dev mode if the cookie is present and preview id is `development-id` then we still treat it as draft mode is enabled. Fixes #52080 Fixes #67075 Closes NEXT-3541
Chnage the way of preview props injection to edge runtime, directly read from env vars of preview props instead of writing to and reading from prerender manifest.js Previously we're trying to make these preview props values become deterministic that we can replace in edge deployment pipeline in #64521 But the way of serializing process env vars in edge runtime is not correct. They'll remain as string "process.env.xxx" in the manifest and also after consumed. This PR fixes that behavior, instead of writing it into manifest, alwyas consuming from process.env.var directly. I created a shared util to access the preview props of edge runtime across all the templates. On draft provider side, we still need to handle dev mode case when preview id is `development-id`, but we already have the cookie, it cannot be aligned with the preview id. So we do a fallback check for dev mode if the cookie is present and preview id is `development-id` then we still treat it as draft mode is enabled. Fixes #52080 Fixes #67075 Closes NEXT-3541
Chnage the way of preview props injection to edge runtime, directly read from env vars of preview props instead of writing to and reading from prerender manifest.js Previously we're trying to make these preview props values become deterministic that we can replace in edge deployment pipeline in #64521 But the way of serializing process env vars in edge runtime is not correct. They'll remain as string "process.env.xxx" in the manifest and also after consumed. This PR fixes that behavior, instead of writing it into manifest, alwyas consuming from process.env.var directly. I created a shared util to access the preview props of edge runtime across all the templates. On draft provider side, we still need to handle dev mode case when preview id is `development-id`, but we already have the cookie, it cannot be aligned with the preview id. So we do a fallback check for dev mode if the cookie is present and preview id is `development-id` then we still treat it as draft mode is enabled. Fixes #52080 Fixes #67075 Closes NEXT-3541
Chnage the way of preview props injection to edge runtime, directly read from env vars of preview props instead of writing to and reading from prerender manifest.js Previously we're trying to make these preview props values become deterministic that we can replace in edge deployment pipeline in #64521 But the way of serializing process env vars in edge runtime is not correct. They'll remain as string "process.env.xxx" in the manifest and also after consumed. This PR fixes that behavior, instead of writing it into manifest, alwyas consuming from process.env.var directly. I created a shared util to access the preview props of edge runtime across all the templates. On draft provider side, we still need to handle dev mode case when preview id is `development-id`, but we already have the cookie, it cannot be aligned with the preview id. So we do a fallback check for dev mode if the cookie is present and preview id is `development-id` then we still treat it as draft mode is enabled. Fixes #52080 Fixes #67075 Closes NEXT-3541
Chnage the way of preview props injection to edge runtime, directly read from env vars of preview props instead of writing to and reading from prerender manifest.js Previously we're trying to make these preview props values become deterministic that we can replace in edge deployment pipeline in #64521 But the way of serializing process env vars in edge runtime is not correct. They'll remain as string "process.env.xxx" in the manifest and also after consumed. This PR fixes that behavior, instead of writing it into manifest, alwyas consuming from process.env.var directly. I created a shared util to access the preview props of edge runtime across all the templates. On draft provider side, we still need to handle dev mode case when preview id is `development-id`, but we already have the cookie, it cannot be aligned with the preview id. So we do a fallback check for dev mode if the cookie is present and preview id is `development-id` then we still treat it as draft mode is enabled. Fixes #52080 Fixes #67075 Closes NEXT-3541
Chnage the way of preview props injection to edge runtime, directly read from env vars of preview props instead of writing to and reading from prerender manifest.js Previously we're trying to make these preview props values become deterministic that we can replace in edge deployment pipeline in #64521 But the way of serializing process env vars in edge runtime is not correct. They'll remain as string "process.env.xxx" in the manifest and also after consumed. This PR fixes that behavior, instead of writing it into manifest, alwyas consuming from process.env.var directly. I created a shared util to access the preview props of edge runtime across all the templates. On draft provider side, we still need to handle dev mode case when preview id is `development-id`, but we already have the cookie, it cannot be aligned with the preview id. So we do a fallback check for dev mode if the cookie is present and preview id is `development-id` then we still treat it as draft mode is enabled. Fixes #52080 Fixes #67075 Closes NEXT-3541
Chnage the way of preview props injection to edge runtime, directly read from env vars of preview props instead of writing to and reading from prerender manifest.js Previously we're trying to make these preview props values become deterministic that we can replace in edge deployment pipeline in #64521 But the way of serializing process env vars in edge runtime is not correct. They'll remain as string "process.env.xxx" in the manifest and also after consumed. This PR fixes that behavior, instead of writing it into manifest, alwyas consuming from process.env.var directly. I created a shared util to access the preview props of edge runtime across all the templates. On draft provider side, we still need to handle dev mode case when preview id is `development-id`, but we already have the cookie, it cannot be aligned with the preview id. So we do a fallback check for dev mode if the cookie is present and preview id is `development-id` then we still treat it as draft mode is enabled. Fixes #52080 Fixes #67075 Closes NEXT-3541
Verify canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #1 SMP PREEMPT_DYNAMIC Thu Jun 15 02:15:40 UTC 2023 Binaries: Node: 18.16.0 npm: 8.11.0 Yarn: 1.22.19 pnpm: N/A Relevant Packages: next: 13.4.8-canary.14 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: 4.9.5 Next.js Config: output: N/A
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true)
Link to the code that reproduces this issue or a replay of the bug
https://github.com/alvarlagerlof/next-js-draft-mode-repro
To Reproduce
Run the repro in dev or build.
Describe the Bug
isEnabled
fromdraftMode()
always returns false withexport const runtime = "edge"
Expected Behavior
isEnabled
returnstrue
afterdraftMode().enable()
is ran,Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
Seems to happen locally, in dev, build, and on Vercel
NEXT-1477
The text was updated successfully, but these errors were encountered: