Workers SDK Issue Reports

← Back to Dashboard

#8280 @cloudflare/vitest-pool-workers deals with `foo.wasm.js` as a wasm module

Recommendation:KEEP OPEN
Difficulty:easy
Reasoning:

Maintainer-confirmed bug: glob-to-regexp dependency doesn't anchor patterns with $, causing *.wasm to match foo.wasm.js. No fix merged in ~11 months despite quick win and vitest:priority labels.

Suggested Action:

Implement fix: replace glob-to-regexp or add $ anchors to pattern regexes for proper end-of-string matching.

Analysis Report

Issue #8280: @cloudflare/vitest-pool-workers deals with foo.wasm.js as a wasm module

Summary

Field Value
Issue #8280
Title @cloudflare/vitest-pool-workers deals with foo.wasm.js as a wasm module
State OPEN
Created 2025-02-27
Updated 2025-10-30
Labels bug, quick win, vitest, vitest:priority
Reporter miyaji255

Problem Description

The @cloudflare/vitest-pool-workers package incorrectly treats JavaScript files containing .wasm anywhere in their filename (e.g., main.wasm.test.js) as WebAssembly modules. This causes the test runner to fail with a module loading error because it attempts to load the JavaScript file as a compiled WebAssembly module.

Error Message

Error: No such module "D:/Users/.../src/main.wasm.test.js?mf_vitest_force=CompiledWasm"

The ?mf_vitest_force=CompiledWasm query parameter indicates the file is being incorrectly identified as a WebAssembly module.

Root Cause Analysis

Maintainer-confirmed bug (petebacondarwin on 2025-02-27):

The issue is caused by a shortcoming in the glob-to-regexp dependency. The library doesn't add $ to the end of the regexes it generates, causing patterns like *.wasm to match not just foo.wasm but also foo.wasm.js, foo.wasm.test.ts, etc.

The pattern matching is too permissive because:

  • Pattern *.wasm generates a regex that matches "contains .wasm" rather than "ends with .wasm"
  • The glob-to-regexp library has been abandoned for several years

Current Status

  • Confirmed bug with identified root cause
  • No fix merged - the issue remains open
  • Labeled as quick win - indicating it should be straightforward to fix
  • Labeled as vitest:priority - indicating priority within vitest issues

Related PRs

  • PR #11094 (OPEN): "[vitest-pool-workers] Allow .wasm files to be imported as .wasm?module" - different issue but same area of code

Possible Solutions (from maintainer comment)

  1. Replace glob-to-regexp with glob-regex package
  2. Vendor the glob-to-regexp code and fix it to add $ anchors

Note: In v0.12.4, glob-to-regexp was bundled into miniflare but the underlying bug was not fixed.

Reproduction

Recommendation

KEEP OPEN

Reasoning

  1. Confirmed bug - Maintainer confirmed this is a bug with clear root cause
  2. No fix merged - Issue has been open ~11 months with no resolution
  3. Labeled priority - Has vitest:priority and quick win labels
  4. Clear solution path - Maintainer identified two possible fixes
  5. Good reproduction - Reporter provided minimal reproduction repo

Suggested Action

Implement the fix by either:

  1. Replacing glob-to-regexp with a properly maintained alternative that correctly anchors patterns
  2. Adding $ anchors to the generated regexes where patterns should match at end-of-string

The fix should ensure that module type detection patterns like *.wasm only match files that actually end with .wasm, not files that contain .wasm anywhere in their path.

Difficulty

Easy - The root cause is identified and the fix is localized to pattern matching logic.

Version Information

Package Report Version Current Version
wrangler 3.110.0 4.60.0
@cloudflare/vitest-pool-workers 0.7.3 0.12.6
vitest 3.0.7 current

Report generated: 2026-01-25

Notes & Feedback (0)

No notes yet.

Add Note