Skip to content

[wrangler] Fix vitest-pool-workers crashing when assets configured without directory#13079

Merged
penalosa merged 1 commit intomainfrom
penalosa/vitest-9381
Mar 27, 2026
Merged

[wrangler] Fix vitest-pool-workers crashing when assets configured without directory#13079
penalosa merged 1 commit intomainfrom
penalosa/vitest-9381

Conversation

@penalosa
Copy link
Copy Markdown
Contributor

@penalosa penalosa commented Mar 26, 2026

Fixes #9381.

When using @cloudflare/vite-plugin, the wrangler config typically has assets: { binding: "ASSETS" } without a directory — the Vite dev server handles asset serving independently. vitest-pool-workers passes the config path to unstable_getMiniflareWorkerOptions, which reads the raw config and calls getAssetsOptions(). That function unconditionally requires directory, so it throws "missing required directory property".

The fix guards the getAssetsOptions() call in both programmatic API callsites (unstable_getMiniflareWorkerOptions and getPlatformProxy) — when no directory is available from either the config or overrides, asset setup is skipped entirely rather than crashing.


  • 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: Bug fix, no new user-facing API

Open with Devin

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 26, 2026

🦋 Changeset detected

Latest commit: 9b3bc68

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 26, 2026

✅ All changesets look good

Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk bot left a comment

Choose a reason for hiding this comment

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

I'm Bonk, and I've done a quick review of your PR.

Guards getAssetsOptions() in both programmatic API callsites so that assets: { binding: "ASSETS" } without a directory no longer crashes.

Issue: The new fixture is missing a root tsconfig.json, which every other fixture in vitest-pool-workers-examples/ has. This means vitest.config.ts in this fixture won't be type-checked by tsc-all.mjs.

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Mar 26, 2026

Review posted successfully on PR #13079. I found one actionable issue:

Missing root tsconfig.json in the new fixture. Every other fixture in vitest-pool-workers-examples/ has a root-level tsconfig.json (extending ../tsconfig.node.json) that covers vitest.config.ts for type-checking via tsc-all.mjs. The new workers-assets-no-dir fixture is the only one missing it, so its vitest.config.ts won't be type-checked during pnpm check:type.

The core logic change in packages/wrangler/src/api/integrations/platform/index.ts is correct — both callsites are properly guarded to skip asset setup when no directory is available.

github run

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 26, 2026

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

wrangler

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

commit: 9b3bc68

@penalosa penalosa marked this pull request as ready for review March 27, 2026 00:32
@penalosa penalosa requested a review from a team as a code owner March 27, 2026 00:32
@penalosa penalosa requested a review from edmundhung March 27, 2026 00:32
@workers-devprod
Copy link
Copy Markdown
Contributor

workers-devprod commented Mar 27, 2026

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@penalosa penalosa force-pushed the penalosa/vitest-9381 branch from 9028ba4 to f1278f5 Compare March 27, 2026 00:33
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Mar 27, 2026
@penalosa penalosa force-pushed the penalosa/vitest-9381 branch from f1278f5 to 9b3bc68 Compare March 27, 2026 13:23
@penalosa penalosa merged commit 746858a into main Mar 27, 2026
58 of 59 checks passed
@penalosa penalosa deleted the penalosa/vitest-9381 branch March 27, 2026 16:20
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Mar 27, 2026
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.

Can't use vitest-pool-workers with vite-plugin

3 participants