Skip to content

Commit bafa5ac

Browse files
fix: use worker name as a script ID when generating a preview session (#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
1 parent d7a48cb commit bafa5ac

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

.changeset/eleven-games-mate.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
fix: use worker name as a script ID when generating a preview session
6+
7+
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.
8+
9+
Fixes https://github.com/cloudflare/wrangler2/issues/1003
10+
Fixes https://github.com/cloudflare/wrangler2/issues/1172

packages/wrangler/src/create-worker-preview.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ async function createPreviewToken(
111111
);
112112

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

0 commit comments

Comments
 (0)