Skip to content

Commit

Permalink
fix: use worker name as a script ID when generating a preview session (
Browse files Browse the repository at this point in the history
…#1192)

When generating a preview session on the edge with `wrangler dev`, for a zoned worker we were using a random id as the script ID. This would make the backend not associate the dev session with any resources that were otherwise assigned to the script (specifically for secrets, but other stuff as well) The fix is simply to use the worker name (when available) as the script ID.

Fixes #1003
Fixes #1172
  • Loading branch information
threepointone authored Jun 6, 2022
1 parent d7a48cb commit bafa5ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .changeset/eleven-games-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"wrangler": patch
---

fix: use worker name as a script ID when generating a preview session

When generating a preview session on the edge with `wrangler dev`, for a zoned worker we were using a random id as the script ID. This would make the backend not associate the dev session with any resources that were otherwise assigned to the script (specifically for secrets, but other stuff as well) The fix is simply to use the worker name (when available) as the script ID.

Fixes https://github.com/cloudflare/wrangler2/issues/1003
Fixes https://github.com/cloudflare/wrangler2/issues/1172
2 changes: 1 addition & 1 deletion packages/wrangler/src/create-worker-preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ async function createPreviewToken(
);

const { accountId } = account;
const scriptId = ctx.zone ? randomId() : worker.name || host.split(".")[0];
const scriptId = worker.name || (ctx.zone ? randomId() : host.split(".")[0]);
const url =
ctx.env && !ctx.legacyEnv
? `/accounts/${accountId}/workers/services/${scriptId}/environments/${ctx.env}/edge-preview`
Expand Down

0 comments on commit bafa5ac

Please sign in to comment.