Skip to content

Allow users to run getPlatformProxy on static asset workers when the assets dir doesn't exist#13116

Merged
dario-piotrowicz merged 8 commits into
mainfrom
dario/allow-dev-and-tests-when-no-assets-dir-exist
Apr 30, 2026
Merged

Allow users to run getPlatformProxy on static asset workers when the assets dir doesn't exist#13116
dario-piotrowicz merged 8 commits into
mainfrom
dario/allow-dev-and-tests-when-no-assets-dir-exist

Conversation

@dario-piotrowicz
Copy link
Copy Markdown
Member

@dario-piotrowicz dario-piotrowicz commented Mar 29, 2026

Users running getPlatformProxy might include in their config file an assets directory that not yet exists. The changes in this PR allow getPlatformProxy to work even if the assets directory doesn't exist yet.

All other commands like wrangler dev and wrangler deploy still fails if the directory doesn't exist at deploy time


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: self-documenting improvement

A picture of a cute animal (not mandatory, but encouraged)


Open with Devin

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 29, 2026

🦋 Changeset detected

Latest commit: e568780

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

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 29, 2026

✅ All changesets look good

ask-bonk[bot]

This comment was marked as resolved.

@ask-bonk

This comment was marked as outdated.

@dario-piotrowicz dario-piotrowicz force-pushed the dario/allow-dev-and-tests-when-no-assets-dir-exist branch from 35a7ee2 to 83fc91d Compare March 29, 2026 22:47
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Mar 29, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@13116

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@13116

miniflare

npm i https://pkg.pr.new/miniflare@13116

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@13116

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@13116

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@13116

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@13116

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@13116

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@13116

wrangler

npm i https://pkg.pr.new/wrangler@13116

commit: e568780

@dario-piotrowicz dario-piotrowicz force-pushed the dario/allow-dev-and-tests-when-no-assets-dir-exist branch from 83fc91d to 5e3a05c Compare March 29, 2026 22:54
@penalosa
Copy link
Copy Markdown
Contributor

How does this compare to #13079?

Base automatically changed from dario/better-error-message-ENOTDIR-assets-dir to main March 30, 2026 13:21
@dario-piotrowicz dario-piotrowicz force-pushed the dario/allow-dev-and-tests-when-no-assets-dir-exist branch from 5e3a05c to e7874c0 Compare March 30, 2026 13:44
@dario-piotrowicz
Copy link
Copy Markdown
Member Author

How does this compare to #13079?

isn't #13079 addressing the case when a directory is not specified in the config file?

this PR instead is handling the case when a directory is specified but doesn't actually (yet) exist on the filesystem

no?

@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review March 30, 2026 13:48
@dario-piotrowicz dario-piotrowicz requested a review from a team as a code owner March 30, 2026 13:48
@workers-devprod
Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • packages/miniflare/src/plugins/assets/index.ts: [@cloudflare/wrangler]
  • packages/miniflare/test/plugins/assets/index.spec.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/assets.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/dev.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/api/integrations/platform/index.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/api/startDevWorker/ConfigController.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/assets.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/deploy/index.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/dev.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/triggers/index.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/versions/upload.ts: [@cloudflare/wrangler]

devin-ai-integration[bot]

This comment was marked as resolved.

@penalosa
Copy link
Copy Markdown
Contributor

@dario-piotrowicz do you have a link to an issue or something where this was discussed? I'm not 100% sure this is a good idea, and I think I would generally expect a missing assets dir to trigger a hard error. Vite deals with this by making the assets dir config field optional, which feels right to me.

@dario-piotrowicz
Copy link
Copy Markdown
Member Author

@dario-piotrowicz do you have a link to an issue or something where this was discussed? I'm not 100% sure this is a good idea, and I think I would generally expect a missing assets dir to trigger a hard error. Vite deals with this by making the assets dir config field optional, which feels right to me.

I thought there was a general consensus that we shouldn't hard error... 🤔

See: https://github.com/cloudflare/workers-sdk/blame/9282493b11ba07bcadb981c2cfc255e8eb5b9b15/packages/wrangler/src/api/integrations/platform/index.ts#L277-L279

@penalosa
Copy link
Copy Markdown
Contributor

@dario-piotrowicz maybe I'm talking nonsense, and definitely feel free to disagree with me! But in general my thinking is:

  • not erroring in getPlatformProxy() makes sense, because that's used at dev time in dev servers that probably haven't built assets yet
  • not erroring when assets directory isn't specified makes sense, because that's either Vite, or a mistake that will give a clear error at dev/deploy-time
  • not erroring when assets directory doesn't exist but is specified seems more dangerous, because there are lots of ways that could happen. In particular, I'd be worried about typos etc... and then a really frustrating debugging experience trying to figure out why assets aren't available

@dario-piotrowicz
Copy link
Copy Markdown
Member Author

@dario-piotrowicz maybe I'm talking nonsense, and definitely feel free to disagree with me! But in general my thinking is:

  • not erroring in getPlatformProxy() makes sense, because that's used at dev time in dev servers that probably haven't built assets yet
  • not erroring when assets directory isn't specified makes sense, because that's either Vite, or a mistake that will give a clear error at dev/deploy-time
  • not erroring when assets directory doesn't exist but is specified seems more dangerous, because there are lots of ways that could happen. In particular, I'd be worried about typos etc... and then a really frustrating debugging experience trying to figure out why assets aren't available

Sounds good 👍 , I'll update the PR accordingly

The only point that I don't fully agree is the last one, if users run something like wrangler dev and the assets dir doesn't exist, I don't see much danger in that since we're talking about local dev anyways, but I understand your point that this could surprise users/create a bit of a frustrating debugging experience 👍

@dario-piotrowicz dario-piotrowicz marked this pull request as draft March 30, 2026 15:39
@dario-piotrowicz dario-piotrowicz force-pushed the dario/allow-dev-and-tests-when-no-assets-dir-exist branch from e7874c0 to 71b33c1 Compare April 26, 2026 17:00
@dario-piotrowicz dario-piotrowicz changed the title Allow users to run local dev or tests on static asset workers when the assets dir doesn't exist Allow users to run getPlatformProxy on static asset workers when the assets dir doesn't exist Apr 27, 2026
@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review April 27, 2026 09:38
@workers-devprod
Copy link
Copy Markdown
Contributor

workers-devprod commented Apr 27, 2026

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

devin-ai-integration[bot]

This comment was marked as resolved.

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Comment thread packages/miniflare/src/plugins/assets/index.ts
Comment thread packages/miniflare/test/plugins/assets/index.spec.ts Outdated
Comment thread packages/miniflare/test/plugins/assets/index.spec.ts Outdated
Comment thread packages/wrangler/src/__tests__/assets.test.ts Outdated
Copy link
Copy Markdown
Contributor

@workers-devprod workers-devprod left a comment

Choose a reason for hiding this comment

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

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Apr 29, 2026
Co-authored-by: Ben <4991309+NuroDev@users.noreply.github.com>
devin-ai-integration[bot]

This comment was marked as resolved.

@dario-piotrowicz dario-piotrowicz force-pushed the dario/allow-dev-and-tests-when-no-assets-dir-exist branch from e5e53da to 467a75c Compare April 29, 2026 23:34
@dario-piotrowicz dario-piotrowicz merged commit e539008 into main Apr 30, 2026
59 of 60 checks passed
@dario-piotrowicz dario-piotrowicz deleted the dario/allow-dev-and-tests-when-no-assets-dir-exist branch April 30, 2026 10:34
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Apr 30, 2026
@dario-piotrowicz
Copy link
Copy Markdown
Member Author

For posterity, I DMed Ben and he did re-review the changes before I merged the PR 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants