Skip to content
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

Fix wrangler config detection with json and toml formats #7799

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

DaniFoldi
Copy link
Contributor

Fixes #[insert GH or internal issue link(s)].

Describe your change...
Assume this (admittedly suboptimal) folder layout:

- my-fancy-worker/
  - worker.ts
  - wrangler.json
  - some-feature
    - some-worker.ts
    - wrangler.toml

Wrangler, without this change, would pick up the outer config file due to the order findUpSync was run in. While it is an edge case, we did run into it with a worker where some functionality has been extracted to a separate one for use with jsrpc, and I was migrating them to use .json instead of .toml.

Fortunately, findUpSync supports an array of strings as input, and even the priority of json > jsonc > toml is kept, if all three are present at the same level.

  • Tests
    • TODO (before merge)
    • Tests included
    • Tests not necessary because: it's such an edge case
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required
    • Not required because:
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Documentation not necessary because: bugfix

@DaniFoldi DaniFoldi requested a review from a team as a code owner January 16, 2025 17:52
Copy link

changeset-bot bot commented Jan 16, 2025

🦋 Changeset detected

Latest commit: 40944d7

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

This PR includes changesets to release 2 packages
Name Type
wrangler Patch
@cloudflare/vitest-pool-workers Patch

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

Copy link
Contributor

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12814728077/npm-package-wrangler-7799

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/7799/npm-package-wrangler-7799

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12814728077/npm-package-wrangler-7799 dev path/to/script.js
Additional artifacts:

cloudflare-workers-bindings-extension:

wget https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12814728077/npm-package-cloudflare-workers-bindings-extension-7799 -O ./cloudflare-workers-bindings-extension.0.0.0-va62ad3220.vsix && code --install-extension ./cloudflare-workers-bindings-extension.0.0.0-va62ad3220.vsix

create-cloudflare:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12814728077/npm-package-create-cloudflare-7799 --no-auto-update

@cloudflare/kv-asset-handler:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12814728077/npm-package-cloudflare-kv-asset-handler-7799

miniflare:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12814728077/npm-package-miniflare-7799

@cloudflare/pages-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12814728077/npm-package-cloudflare-pages-shared-7799

@cloudflare/unenv-preset:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12814728077/npm-package-cloudflare-unenv-preset-7799

@cloudflare/vitest-pool-workers:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12814728077/npm-package-cloudflare-vitest-pool-workers-7799

@cloudflare/workers-editor-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12814728077/npm-package-cloudflare-workers-editor-shared-7799

@cloudflare/workers-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12814728077/npm-package-cloudflare-workers-shared-7799

@cloudflare/workflows-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12814728077/npm-package-cloudflare-workflows-shared-7799

Note that these links will no longer work once the GitHub Actions artifact expires.


[email protected] includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20241230.2
workerd 1.20241230.0 1.20241230.0
workerd --version 1.20241230.0 2024-12-30

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

@DaniFoldi
Copy link
Contributor Author

Hey team,

From the failing test it looks like this was intentional. Was there a specific use case in mind? If so, I can close this PR, as now that I have migrated our root worker, I shouldn't run into this again.

Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the intention was to look for any wrangler.json before looking for any wrangler.toml. But I guess this could be reconsidered...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Untriaged
Development

Successfully merging this pull request may close these issues.

2 participants