Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@dario-piotrowicz
Copy link
Member

Fixes https://jira.cfdata.org/browse/DEVX-2321


  • Tests
    • Tests included
    • Tests not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: tracked elsewhere
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: not in v3

@changeset-bot
Copy link

changeset-bot bot commented Nov 16, 2025

🦋 Changeset detected

Latest commit: 38859dc

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Nov 16, 2025
@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2321/autoconfig-nextjs branch from e1a384a to 31e5296 Compare November 16, 2025 18:13
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 16, 2025

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@11301

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@11301

miniflare

npm i https://pkg.pr.new/miniflare@11301

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@11301

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@11301

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@11301

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@11301

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@11301

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@11301

wrangler

npm i https://pkg.pr.new/wrangler@11301

commit: b88b00f

@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2321/autoconfig-nextjs branch from 31e5296 to 20d1242 Compare November 16, 2025 18:49
@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2321/autoconfig-nextjs branch from 20d1242 to a2f24b5 Compare November 17, 2025 10:37
@dario-piotrowicz dario-piotrowicz force-pushed the penalosa/autoconfig-sveltekit branch from b1d0f1b to ba94707 Compare November 17, 2025 11:27
@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2321/autoconfig-nextjs branch from a2f24b5 to a087f96 Compare November 17, 2025 11:28
Base automatically changed from penalosa/autoconfig-sveltekit to main November 17, 2025 14:06
@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2321/autoconfig-nextjs branch from a087f96 to db411f0 Compare November 17, 2025 14:09
@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review November 17, 2025 14:09
@dario-piotrowicz dario-piotrowicz requested a review from a team as a code owner November 17, 2025 14:09
@dario-piotrowicz
Copy link
Member Author

Converting to draft since the C3 e2es don't currently run in CI and we should enable them before merging and new C3 autoconfig PR

@dario-piotrowicz dario-piotrowicz marked this pull request as draft November 17, 2025 16:25
@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2321/autoconfig-nextjs branch from db411f0 to 9845bde Compare November 17, 2025 23:07
@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review November 18, 2025 17:30
@ascorbic
Copy link
Contributor

When I tried this locally, with a new project, I got "✘ [ERROR] The entry-point file at ".open-next/worker.js" was not found.". I needed to do another npm run deploy manually

@ascorbic
Copy link
Contributor

The issue is that it doesn't run opennextjs-cloudflare build. I'm not sure what the best workaround is here.

@ascorbic
Copy link
Contributor

Should it change the build command?

@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2321/autoconfig-nextjs branch 2 times, most recently from 69a48af to 73871b5 Compare November 27, 2025 11:28
@dario-piotrowicz
Copy link
Member Author

Should it change the build command?

oh... yeah I see the issue.... that's annoying.... I don't think we could change the build command since that's for example used by the Vercel CLI and changing it can have some unexpected consequences... 🤔 I think we should ideally let wrangler deploy know the build command that it needs to run? 🤔

@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2321/autoconfig-nextjs branch from 73871b5 to 0927724 Compare November 27, 2025 18:43
@dario-piotrowicz
Copy link
Member Author

@ascorbic WDYT?

0927724

@ascorbic
Copy link
Contributor

0927724

I think these changes should be in a separate PR. Will they then override the package.json build command too?

@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2321/autoconfig-nextjs branch from 541281c to 3e2729c Compare December 11, 2025 17:25
@dario-piotrowicz dario-piotrowicz merged commit 6c590a0 into main Dec 15, 2025
33 checks passed
@dario-piotrowicz dario-piotrowicz deleted the dario/DEVX-2321/autoconfig-nextjs branch December 15, 2025 11:32
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Dec 15, 2025
@lrapoport-cf lrapoport-cf mentioned this pull request Dec 16, 2025
6 tasks
edmundhung added a commit that referenced this pull request Dec 16, 2025
@diegohaz
Copy link

I’ll try to create a minimal reproduction later, but I think the open-next project detection might be too permissive. I have a Wrangler config at the repo root that deploys an Astro app. Then I have a workspace with a Next.js app that uses open-next. The issue is that when I deploy the root app, it gets identified as an open-next project, which is incorrect, and it results in this error:

A screenshot of a terminal log during a 'Deploy app version' step. It detects an OpenNext project and calls opennextjs-cloudflare deploy, but fails with 'ERROR Could not find compiled Open Next config, did you run the build command?'. The process exits with code 1.

See https://github.com/ariakit/ariakit/actions/runs/20287760629/job/58265344982

@jkribeiro
Copy link

Do you have this documented somewhere? Because in my case, the new Wrangler version (4.55.0) is not respecting the deployment parameters, such as --env, --name and --dispatch-namespace.

As showing below, first it runs Wrangler deploy with some parameters, then it calls opennextjs-cloudflare deploy without any parameter.

Running Wrangler Commands
  /opt/actions-runner/_work/_tool/node/20.19.6/x64/bin/npx wrangler deploy --name projectcom-dev-merge-17-dec --env=nonprod --dispatch-namespace wfp
  Proxy environment variables detected. We'll use your proxy for fetch requests.
  
   ⛅️ wrangler 4.55.0
  ───────────────────
  OpenNext project detected, calling `opennextjs-cloudflare deploy`
  Proxy environment variables detected. We'll use your proxy for fetch requests.
  
  ┌──────────────────────────────┐
  │ OpenNext — Cloudflare deploy │
  └──────────────────────────────┘
  
  Incremental cache does not need populating
  Tag cache does not need populating
  Proxy environment variables detected. We'll use your proxy for fetch requests.
  
   ⛅️ wrangler 4.55.0
  ───────────────────
  ▲ [WARNING] Multiple environments are defined in the Wrangler configuration file, but no target environment was specified for the deploy command.
  
    To avoid unintentional changes to the wrong environment, it is recommended to explicitly specify the target environment using the `-e|--env` flag.
    If your intention is to use the top-level environment of your configuration simply pass an empty string to the flag to target such environment. For example `--env=""`.

@DBosley
Copy link

DBosley commented Dec 20, 2025

This change just took down a production site because --env wasn't passed to the opennext deploy. When it failed, it assigned the prod custom domains to our staging env and stole them from the prod deploy. This happened completely isolated in the staging worker. The cloudflare infra just let a config value take the custom domains from our prod instance and apply them to the staging instance like it was no problem.

meanwhile the sites that used routes instead failed with an error saying the route was already in use

@pliashkou
Copy link

pliashkou commented Dec 24, 2025

@dario-piotrowicz We deploy our apps to Workers for Platforms by setting --dispatch-namespace for wrangler deploy. With new version of wrangler it doesn't work anymore. How can I disable it?

@MattieTK
Copy link
Member

MattieTK commented Dec 24, 2025

@pliashkou you can temporarily pin your wrangler version to 4.54 to avoid this. We have made some improvements in 4.56 which should have resolved the OpenNext priority issue for detection, but if that's still broken for you pinning a previous version will get you around the problem whilst we investigate. For safety we have deprecated 4.55 and 4.56 until after the holidays.

To do this you can specifically target the version of wrangler via npx wrangler@version deploy so npx [email protected] deploy

@elithrar
Copy link
Contributor

elithrar commented Dec 24, 2025

@diegohaz @jkribeiro - see the above comment re: pinning to 4.54.

we have deprecated 4.55 and 4.56 due to this regression.

AmirSa12 pushed a commit to AmirSa12/workers-sdk that referenced this pull request Jan 5, 2026
…ngler deploy` runs executed in open-next projects (cloudflare#11301)

* Support Next.js in autoconfig

* Update packages/wrangler/src/autoconfig/frameworks/next.ts

Co-authored-by: Somhairle MacLeòid <[email protected]>

* update `AutoConfigFrameworkConfigurationError` class to extend `UserError`

* add WORKER_SELF_REFERENCE service config

* delegate deploy to open-next for open-next projects

* move next to the right framework position

* move scripts to `packageJsonScriptsOverrides`

* fix packageJsonScriptsOverrides not being passed to buildOperationsSummary

* add OpenNext to changesets

* improve jsdoc comment for `maybeDelegateToOpenNextDeployCommand`

* update OpenNext log

* test whole `std` with single `toMatchInlineSnapshot`

* rename probeForNextConfigPath to findNextConfigPath

* Update packages/wrangler/src/deploy/open-next.ts

Co-authored-by: Somhairle MacLeòid <[email protected]>

* move `OPEN_NEXT_DEPLOY` to `misc-variables`

* move openNext delegation after autoconfig logic

* simplify comment

---------

Co-authored-by: Somhairle MacLeòid <[email protected]>
AmirSa12 pushed a commit to AmirSa12/workers-sdk that referenced this pull request Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.