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

Separate config for workers_dev_previews #7227

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

Conversation

taylorlee
Copy link
Contributor

@taylorlee taylorlee commented Nov 11, 2024

Fixes WC-2914

Add workers_dev_previews toggle to wrangler.toml

The current Preview URLs (beta) feature routes to version preview urls based on the status of the workers_dev config value. Beta users have requested the ability to enable deployment urls and preview urls separately on workers.dev, and the new previews_enabled field of the enable-subdomain API will allow that. This change separates the workers_dev and workers_dev_previews behavior during wrangler triggers deploy and wrangler versions upload. wrangler_dev_previews defaults to true, and does not implicitly depend on routes the way wrangler_dev does.

TODO

  • blocked on API release

  • Tests

    • Tests included
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)

    • Required
  • Public documentation

    • TODO (before merge)

Many tests had mocks that weren't called,
or had false assertions about not updating subdomain routes when they
actually were being updated.

Additionally, available_on_subdomain is now unecessary during
script-upload, as it is not read there, due to being handled entirely
within triggers-deploy. This also saves a double call to get /subdomain
in the new-api path.

The get/update subdomain helpers are refactored from deploy/version
tests, and unified to standardize default workername and legacyEnv.

I wanted to remove the getSubdomain mock from mockUpload entirely, but
there were a bit too many callsites... At least every test now that
makes assertions about workers.dev deployments does explicitly reset the
mock return value.
@taylorlee taylorlee requested a review from a team as a code owner November 11, 2024 16:55
Copy link

changeset-bot bot commented Nov 11, 2024

🦋 Changeset detected

Latest commit: 40665e2

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

This PR includes changesets to release 2 packages
Name Type
wrangler Minor
@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

});
}
if (!deployToWorkersDev && deploymentInSync && routes.length !== 0) {
// TODO is this true? How does last subdomain status affect route confict??
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I kept this unchanged (aside from unrolling the conditional branches for easier context readability), but I don't think this branch makes sense anymore.

Copy link
Contributor

github-actions bot commented Nov 11, 2024

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/11785260416/npm-package-wrangler-7227

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

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

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11785260416/npm-package-wrangler-7227 dev path/to/script.js
Additional artifacts:
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11785260416/npm-package-create-cloudflare-7227 --no-auto-update
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11785260416/npm-package-cloudflare-kv-asset-handler-7227
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11785260416/npm-package-miniflare-7227
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11785260416/npm-package-cloudflare-pages-shared-7227
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11785260416/npm-package-cloudflare-vitest-pool-workers-7227
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11785260416/npm-package-cloudflare-workers-editor-shared-7227
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11785260416/npm-package-cloudflare-workers-shared-7227
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11785260416/npm-package-cloudflare-workflows-shared-7227

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


wrangler@3.86.0 includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20241106.0
workerd 1.20241106.1 1.20241106.1
workerd --version 1.20241106.1 2024-11-06

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

@penalosa
Copy link
Contributor

Sorry to bikeshed on this, but I'm not sure about the name here. I know previews are always on workers.dev for now, but I imagine at some point in the future we might want to support previews on a custom domain/zone the user controls? Is there any reason we can't call this something like worker_previews or preview_urls?

The current Preview URLs (beta) feature routes to version preview urls based on the status of the `workers_dev` config value. Beta users have requested the ability to enable deployment urls and preview urls separately on `workers.dev`, and the new `previews_enabled` field of the enable-subdomain API will allow that. This change separates the `workers_dev` and `workers_dev_previews` behavior during `wrangler triggers deploy` and `wrangler versions upload`. `wrangler_dev_previews` defaults to true, and does not implicitly depend on routes the way `wrangler_dev` does.
@taylorlee taylorlee force-pushed the tlee/preview-url-separate-subdomain-toggle-2 branch from 6ca4cbf to 40665e2 Compare November 11, 2024 19:53
headers: {
"Content-Type": "application/json",
},
})
.then(() => [scriptURL])
.then(() => [deploymentURL])
// Add a delay when the subdomain is first created.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Incidentally, we should probably remove this. Avoiding negative dns cache is important during the first ~30 seconds of subdomain registration, but is not relevant when enabling the subdomain route of a particular Worker.

@taylorlee
Copy link
Contributor Author

Sorry to bikeshed on this, but I'm not sure about the name here. I know previews are always on workers.dev for now, but I imagine at some point in the future we might want to support previews on a custom domain/zone the user controls? Is there any reason we can't call this something like worker_previews or preview_urls?

Definitely open to change! Any of worker_previews, preview_urls, or worker_preview_urls seems reasonable to me. What is your preference?

@korinne
Copy link

korinne commented Nov 12, 2024

After a quick chat with everyone, we decided preview_urls works best. Thanks @penalosa and @taylorlee!

Base automatically changed from tlee/preview-url-separate-subdomain-toggle to main November 13, 2024 16:45
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.

4 participants