-
Notifications
You must be signed in to change notification settings - Fork 67
Description
Describe the bug
When running opennextjs-cloudflare preview --remote
with a preview_id defined in wrangler.toml, OpenNext attempts to populate the KV cache via wrangler kv:bulk put
, but it does not pass the required --preview
flag to Wrangler. So we get error of this
[ERROR] NEXT_INC_CACHE_KV has both a namespace ID and a preview ID. Specify "--preview" or "--preview false" to avoid writing data to the wrong namespace.
Steps to reproduce
- Add KV for cache in wrangler config
[[kv_namespaces]]
binding = "NEXT_INC_CACHE_KV"
id = "xxxxxxxxxxxxxx"
preview_id = "xxxxxxxxxx"
(preview_id seems required by wrangler, otherwise you will get error:
In development, you should use a separate kv namespace than the one you'd use in production. Please create a new kv namespace with "wrangler kv namespace create --preview" and add its id as preview_id to the kv_namespace "NEXT_INC_CACHE_KV" in your wrangler.toml file)
- enable kvIncrementalCach in opennext config
export default defineCloudflareConfig({
incrementalCache: kvIncrementalCache,
});
- run
opennextjs-cloudflare build && opennextjs-cloudflare preview --remote
error get:
NEXT_INC_CACHE_KV has both a namespace ID and a preview ID. Specify "--preview" or "--preview false" to avoid writing data to the wrong namespace.
Expected behavior
Opennext should set the --preview flag to wrangler put command, or provides a way for us to pass custom wrangler args from cli.
(I can't find how to pass through args in doc, please let me know if I missed it)
@opennextjs/cloudflare version
1.6.1
Wrangler version
4.26
next info output
Using vars defined in .dev.vars
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:29 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6030
Available memory (MB): 18432
Available CPU cores: 12
Binaries:
Node: 22.16.0
npm: 10.9.2
Yarn: 1.22.22
pnpm: 10.14.0
Relevant Packages:
next: 15.3.2 // There is a newer version (15.5.3) available, upgrade recommended!
eslint-config-next: 15.3.2
react: 19.1.0
react-dom: 19.1.0
typescript: 5.8.3
Next.js Config:
output: N/A
⚠ There is a newer version (15.5.3) available, upgrade recommended!
Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
Read more - https://nextjs.org/docs/messages/opening-an-issue