[Workers Assets] _headers updates are dropped when wrangler deploy hits "No updated asset files to upload"
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- backend-api-design, cli
Research direction
Start by tracing how Wrangler handles static asset uploads during wrangler versions upload and wrangler deploy, especially the empty upload-session path that logs “No updated asset files to upload.” Compare how the _headers metadata is submitted and carried into the new Worker version when assets are uploaded versus when the upload is empty. Done means the deployed version retains the submitted _headers rules even when no asset files need uploading.
Written by the indexing model from the issue text.
Description
What versions & operating system are you using?
- Wrangler:
4.166.0(running in Cloudflare Workers Builds, Linux x64) - Node:
24.22.1, pnpm:12.10.1 - Framework / Adapter:
[email protected],@astrojs/[email protected](redirecteddist/server/wrangler.jsonwithassets.directory = "../client")
Please provide a link to a minimal reproduction
Public repository where this reproduced twice in a row on Workers Builds: https://github.com/withxat/ImI (see public/_headers added/updated in commit 46a9690 / PR #37, and again across PR #38).
Describe the Bug
When a Workers Builds PR preview runs npx wrangler versions upload and uploads new/modified static assets along with an updated _headers file, the resulting preview Worker version stores the updated _headers correctly in resources.script_runtime.assets.raw_headers and resources.script_runtime.assets.headers.rules.
Minutes later, when the same PR is merged to main and Workers Builds runs npx wrangler deploy, /assets-upload-session returns empty buckets (No updated asset files to upload. Proceeding with deployment...) because the preview build already uploaded the identical static asset hashes. On that wrangler deploy, the newly created production Worker version silently drops the _headers update and reverts raw_headers / headers.rules to the previous production _headers (from before PR #37).
Evidence across 5 consecutive builds (same repo, config, and Wrangler version)
Every commit below has the Content-Security-Policy line under /* in public/_headers, and every build log confirms Vite + @astrojs/cloudflare generated a fresh dist/client/_headers (logging ✨ Parsed 12 valid header rules. and [@astrojs/cloudflare] Injected immutable Cache-Control for /_astro/* into _headers., which @astrojs/cloudflare only logs when dist/client/_headers does not already contain /_astro/*):
| Worker Version | Branch / Commit | Deploy command | Asset upload result | assets.raw_headers includes new Content-Security-Policy |
|---|---|---|---|---|
| #288 | PR #37 preview (46a9690) |
npx wrangler versions upload |
Uploaded new static assets | Yes |
| #289 | main (868e5e4, PR #37 merge) |
npx wrangler deploy |
Assets already uploaded by #288 | No (reverted to pre-PR #37 _headers) |
| #290 | main (db8acc9, docs-only) |
npx wrangler deploy |
No updated asset files to upload |
No |
| #291 | PR #38 preview (ae425e5) |
npx wrangler versions upload |
Found 35 new or modified static assets |
Yes |
| #292 | main (d6c14d5, PR #38 merge) |
npx wrangler deploy |
No updated asset files to upload |
No (reverted to pre-PR #37 _headers again) |
Expected Behavior
metadata.assets.config._headers submitted with wrangler deploy should always update assets.raw_headers and assets.headers.rules on the new Worker version, even when /assets-upload-session returns empty buckets (No updated asset files to upload) — otherwise any _headers-only edit or PR merge following a preview upload cannot take effect in production.
Reproduction Steps
- Configure a Worker with Static Assets and Cloudflare Workers Builds (PR previews running
npx wrangler versions upload,maindeploys runningnpx wrangler deploy). - Open a PR that edits
public/_headers(e.g. adds aContent-Security-Policyheader under/*) along with static asset changes. - After the PR preview build succeeds, inspect
GET /accounts/{account_id}/workers/scripts/{script_name}/versions/{version_id}—resources.script_runtime.assets.raw_headersandheaders.rules["/*"].setcontain the new header. - Merge the PR to
mainso Workers Builds runsnpx wrangler deployand logsNo updated asset files to upload. Proceeding with deployment.... - Inspect the newly deployed production version via the same API and check static asset HTTP response headers — the new header is missing and
raw_headershas reverted to the older production_headers.
Please provide any relevant error logs
No errors or warnings are emitted in either build.
PR #38 preview (wrangler versions upload -> version #291, _headers updated):
06:06:37 [vite] ✓ 109 assets moved from "ssr" to "client" build output.
✨ Parsed 12 valid header rules.
06:06:38 [build] Rearranging server assets...
06:06:38 [@astrojs/cloudflare] Injected immutable Cache-Control for /_astro/* into _headers.
Executing user deploy command: npx wrangler versions upload
🌀 Building list of assets...
✨ Read 504 files from the assets directory /opt/buildhome/repo/dist/client
🌀 Starting asset upload...
🌀 Found 35 new or modified static assets to upload. Proceeding with upload...
✨ Success! Uploaded 35 files (452 already uploaded) (1.06 sec)
Uploaded imi (3.39 sec)
main merge 2 minutes later (wrangler deploy -> version #292, _headers reverted):
06:08:41 [vite] ✓ 109 assets moved from "ssr" to "client" build output.
✨ Parsed 12 valid header rules.
06:08:42 [build] Rearranging server assets...
06:08:42 [@astrojs/cloudflare] Injected immutable Cache-Control for /_astro/* into _headers.
Executing user deploy command: npx wrangler deploy
🌀 Building list of assets...
✨ Read 504 files from the assets directory /opt/buildhome/repo/dist/client
🌀 Starting asset upload...
No updated asset files to upload. Proceeding with deployment...
Uploaded imi (3.31 sec)
Deployed imi triggers (0.48 sec)
- Dominant language
- TypeScript
- Stars
- 4.7k
- Forks
- 1.7k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 282
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cloudflare/workers-sdk
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
cloudflare/workers-sdk#17215 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
cloudflare/workers-sdk#17189 · 3 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
cloudflare/workers-sdk#17187 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
cloudflare/workers-sdk#17175 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
cloudflare/workers-sdk#17174 ·
Maintainers usually reply within 1 day
All issues in cloudflare/workers-sdk
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
earendil-works/pi#12615 ·
Maintainers usually reply within 1 day
-
My Caps shows "Shared" on private Caps that were never sharedPossibly taken @AksharP5 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
CapSoftware/Cap#4569 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
OHDSI/Data2Evidence#3749 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Flagsmith/flagsmith-nodejs-client#332 ·
Maintainers usually reply within 2 days