Skip to content

[miniflare] Fix glob patterns matching double-extension filenames#13080

Merged
penalosa merged 2 commits intomainfrom
penalosa/vitest-8280
Mar 27, 2026
Merged

[miniflare] Fix glob patterns matching double-extension filenames#13080
penalosa merged 2 commits intomainfrom
penalosa/vitest-8280

Conversation

@penalosa
Copy link
Copy Markdown
Contributor

@penalosa penalosa commented Mar 26, 2026

Fixes #8280.

globsToRegExps compiles glob patterns using glob-to-regexp with flags: "g", which strips both ^ and $ anchors. The code already reconstructed each regex without the g flag, but didn't restore $ — so a pattern like **/*.wasm would match any path containing .wasm as a substring, including foo.wasm.js or main.wasm.test.ts.

This primarily affects @cloudflare/vitest-pool-workers users with a wrangler.configPath set, since Wrangler's default module rules include { type: "CompiledWasm", globs: ["**/*.wasm"] }. Test files with .wasm in their name (e.g. main.wasm.test.ts) would be incorrectly tagged as WebAssembly modules and fail to load.

The fix appends $ to each compiled regex source. The leading ^ stays absent — this is intentional so patterns can match anywhere within an absolute path.


  • 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 with no user-facing API changes

Open with Devin

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 26, 2026

🦋 Changeset detected

Latest commit: b85adb9

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

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Mar 26, 2026

The fix is clean, correct, and well-tested. Let me verify the logic once more:

  1. glob-to-regexp with flags: "g" strips both ^ and $ anchors from the generated regex.
  2. The old code reconstructed the regex without g flag but didn't restore the $ anchor.
  3. The fix appends $ to the .source of the compiled regex, which correctly anchors the match to the end of the string.
  4. Not restoring ^ is intentional to allow absolute path matching (e.g., /abs/path/to/foo.wasm matching **/*.wasm).

The unit tests cover both positive and negative cases. The fixture test provides an integration-level regression test. The changeset is correctly scoped to miniflare as a patch. The code change is minimal and targeted.

LGTM

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@13080

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

wrangler

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

commit: b85adb9

@penalosa penalosa marked this pull request as ready for review March 27, 2026 00:33
@penalosa penalosa requested a review from a team as a code owner March 27, 2026 00:33
@penalosa penalosa requested a review from jamesopstad March 27, 2026 00:33
@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

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 3 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 merged commit f4ea4ac into main Mar 27, 2026
51 of 55 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Mar 27, 2026
@penalosa penalosa deleted the penalosa/vitest-8280 branch March 27, 2026 13:20
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.

🐛 BUG: @cloudflare/vitest-pool-workers deals with foo.wasm.js as a wasm module

3 participants