diff --git a/.changeset/famous-mayflies-knock.md b/.changeset/famous-mayflies-knock.md index 999346dd1bb1..18acd68ef69d 100644 --- a/.changeset/famous-mayflies-knock.md +++ b/.changeset/famous-mayflies-knock.md @@ -2,6 +2,6 @@ "wrangler": minor --- -Add `workers_dev_previews` toggle to `wrangler.toml` +Add `preview_urls` 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. +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 `preview_urls` 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. diff --git a/packages/wrangler/src/__tests__/configuration.test.ts b/packages/wrangler/src/__tests__/configuration.test.ts index fbafa6edfe83..98a18fd9a9bf 100644 --- a/packages/wrangler/src/__tests__/configuration.test.ts +++ b/packages/wrangler/src/__tests__/configuration.test.ts @@ -120,7 +120,7 @@ describe("normalizeAndValidateConfig()", () => { wasm_modules: undefined, data_blobs: undefined, workers_dev: undefined, - workers_dev_previews: true, + preview_urls: true, zone_id: undefined, no_bundle: undefined, minify: undefined, diff --git a/packages/wrangler/src/__tests__/deploy.test.ts b/packages/wrangler/src/__tests__/deploy.test.ts index e91ecb82b409..fa4b280f5bd1 100644 --- a/packages/wrangler/src/__tests__/deploy.test.ts +++ b/packages/wrangler/src/__tests__/deploy.test.ts @@ -5073,7 +5073,7 @@ addEventListener('fetch', event => {});` it("should sync the workers.dev domain if it has been enabled before but previews should be enabled", async () => { writeWranglerToml({ workers_dev: true, - workers_dev_previews: false, + preview_urls: false, }); writeWorkerSource(); mockUploadWorkerRequest(); @@ -5161,7 +5161,7 @@ addEventListener('fetch', event => {});` it("should sync the workers.dev domain if it is not available but previews should be disabled", async () => { writeWranglerToml({ workers_dev: false, - workers_dev_previews: false, + preview_urls: false, }); writeWorkerSource(); mockUploadWorkerRequest(); diff --git a/packages/wrangler/src/__tests__/versions/versions.upload.test.ts b/packages/wrangler/src/__tests__/versions/versions.upload.test.ts index 4d24605a9d2d..1dcf69fb77f8 100644 --- a/packages/wrangler/src/__tests__/versions/versions.upload.test.ts +++ b/packages/wrangler/src/__tests__/versions/versions.upload.test.ts @@ -140,7 +140,7 @@ describe("versions upload", () => { `); }); - it("should not print preview url when workers_dev_previews is false", async () => { + it("should not print preview url when preview_urls is false", async () => { mockGetScript(); mockUploadVersion(true); mockGetWorkerSubdomain({ enabled: true, previews_enabled: false }); diff --git a/packages/wrangler/src/config/config.ts b/packages/wrangler/src/config/config.ts index 1419b5898bdb..22ef68570ee6 100644 --- a/packages/wrangler/src/config/config.ts +++ b/packages/wrangler/src/config/config.ts @@ -355,7 +355,7 @@ export const defaultWranglerConfig: Config = { preserve_file_names: undefined, base_dir: undefined, workers_dev: undefined, - workers_dev_previews: true, + preview_urls: true, route: undefined, routes: undefined, tsconfig: undefined, diff --git a/packages/wrangler/src/config/environment.ts b/packages/wrangler/src/config/environment.ts index 2b07b25da967..99a9446561cb 100644 --- a/packages/wrangler/src/config/environment.ts +++ b/packages/wrangler/src/config/environment.ts @@ -155,7 +155,7 @@ interface EnvironmentInheritable { * @default `true` * @inheritable */ - workers_dev_previews: boolean | undefined; + preview_urls: boolean | undefined; /** * A list of routes that your Worker should be published to. diff --git a/packages/wrangler/src/config/validation.ts b/packages/wrangler/src/config/validation.ts index dda3cdb37e01..949f723a1271 100644 --- a/packages/wrangler/src/config/validation.ts +++ b/packages/wrangler/src/config/validation.ts @@ -1121,11 +1121,11 @@ function normalizeAndValidateEnvironment( undefined ); - const workers_dev_previews = inheritable( + const preview_urls = inheritable( diagnostics, topLevelEnv, rawEnv, - "workers_dev_previews", + "preview_urls", isBoolean, true ); @@ -1264,7 +1264,7 @@ function normalizeAndValidateEnvironment( placement: normalizeAndValidatePlacement(diagnostics, topLevelEnv, rawEnv), build, workers_dev, - workers_dev_previews, + preview_urls, // Not inherited fields vars: notInheritable( diagnostics, diff --git a/packages/wrangler/src/init.ts b/packages/wrangler/src/init.ts index ef5f463bf528..3efd5792681a 100644 --- a/packages/wrangler/src/init.ts +++ b/packages/wrangler/src/init.ts @@ -941,7 +941,7 @@ async function getWorkerConfig( name: workerName, main: entrypoint, workers_dev: workersDev.enabled, - workers_dev_previews: workersDev.previews_enabled, + preview_urls: workersDev.previews_enabled, compatibility_date: serviceEnvMetadata.script.compatibility_date ?? new Date().toISOString().substring(0, 10), diff --git a/packages/wrangler/src/triggers/deploy.ts b/packages/wrangler/src/triggers/deploy.ts index b10d37b280e4..4e516945a436 100644 --- a/packages/wrangler/src/triggers/deploy.ts +++ b/packages/wrangler/src/triggers/deploy.ts @@ -5,7 +5,6 @@ import { publishCustomDomains, publishRoutes, renderRoute, - sleep, updateQueueConsumers, updateQueueProducers, validateRoutes, @@ -96,7 +95,7 @@ export default async function triggersDeploy( const deploymentInSync = deployToWorkersDev === available_on_subdomain; const previewsInSync = - config.workers_dev_previews === previews_available_on_subdomain; + config.preview_urls === previews_available_on_subdomain; if (deployToWorkersDev) { // Deploy to a subdomain of `workers.dev` @@ -116,21 +115,12 @@ export default async function triggersDeploy( method: "POST", body: JSON.stringify({ enabled: true, - previews_enabled: config.workers_dev_previews, + previews_enabled: config.preview_urls, }), headers: { "Content-Type": "application/json", }, - }) - .then(() => [deploymentURL]) - // Add a delay when the subdomain is first created. - // This is to prevent an issue where a negative cache-hit - // causes the subdomain to be unavailable for 30 seconds. - // This is a temporary measure until we fix this on the edge. - .then(async (url) => { - await sleep(3000); - return url; - }) + }).then(() => [deploymentURL]) ); } } @@ -140,7 +130,7 @@ export default async function triggersDeploy( method: "POST", body: JSON.stringify({ enabled: false, - previews_enabled: config.workers_dev_previews, + previews_enabled: config.preview_urls, }), headers: { "Content-Type": "application/json",