Fix WebAssembly error when importing astro:actions in Cloudflare Vitest tests by matthewp · Pull Request #17943 · withastro/astro · GitHub
Skip to content

Fix WebAssembly error when importing astro:actions in Cloudflare Vitest tests - #17943

Merged
ematipico merged 5 commits into
mainfrom
fix/17906-actions-cf-vitest-wasm
Sep 9, 2026
Merged

ematipico merged 5 commits into
mainfrom
fix/17906-actions-cf-vitest-wasm

Conversation

@matthewp

@matthewp matthewp commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Changes

Importing astro:actions in Cloudflare Vitest tests triggered a WebAssembly error. Its runtime code path loaded es-module-lexer, which compiles WebAssembly when the module loads, and the workerd runtime disallows that.

The only consumer of es-module-lexer was a dev-time check for whether the project has an actions file. I moved that check into its own module that only Astro's config and build tooling loads — code that always runs in Node, never in a user's test runtime.

Importing astro:actions no longer reaches es-module-lexer, so the error can't happen.

Testing

Adds an integration test that runs @cloudflare/vitest-pool-workers against a fixture importing astro:actions in a real workerd isolate — the exact setup from the issue. It fails against the pre-fix build with the reported WebAssembly.compile() unhandled rejection and passes with the fix. Replaces a unit test that inspected the import graph statically.

Docs

No docs update needed; this is an internal refactor with no user-facing change.

Importing astro:actions in Cloudflare Vitest tests (workerd) triggered
es-module-lexer's WebAssembly init at module evaluation, which the runtime
disallows, producing an unhandled rejection. The dev-time actions file
check now lives in a build-only module, so the runtime graph has no
reference to the lexer. (#17906)
@changeset-bot

changeset-bot Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

@github-actions github-actions Bot added the pkg: astro Related to the core `astro` package (scope) label Sep 8, 2026
@codspeed

codspeed Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 21 untouched benchmarks


Comparing fix/17906-actions-cf-vitest-wasm (7185196) with main (e294953)

Open in CodSpeed

Replaces the static import-graph unit test with an integration test that
imports astro:actions under @cloudflare/vitest-pool-workers, reproducing
the exact workerd failure from #17906: the pre-fix build fails the vitest
run with the WebAssembly.compile unhandled rejection, the fixed build
passes cleanly.
@github-actions github-actions Bot added the pkg: integration Related to any renderer integration (scope) label Sep 8, 2026
Superseded by the Cloudflare vitest pool integration test added in the
previous commit, which loads astro:actions in workerd.
@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Dependency Count

This PR adds 19 new dependencies (2189 → 2208), which exceeds the threshold of 10.

⚠️ New Duplicate Dependencies (found: 18, threshold: 1)

📦 Package 📋 Versions
vitest
3 versions
  • root@
    • vitest@4.1.0

vitest@4.1.10
vitest@5.0.0-beta.3
zod
5 versions
zod@3.25.76
zod@4.1.11
  • root@
    • @earendil-works/pi-ai@0.83.0
      • @anthropic-ai/sdk@0.91.1
        • zod@4.3.6

zod@4.4.3
  • root@
    • @flue/runtime@2.0.3
      • @earendil-works/pi-agent-core@0.83.0
        • @earendil-works/pi-ai@0.83.0
          • @anthropic-ai/sdk@0.91.1
            • zod@4.5.4

workerd
2 versions
workerd@1.20260815.1
workerd@1.20260820.1
miniflare
2 versions
miniflare@5.20260815.0-alpha
miniflare@5.20260820.0-alpha
wrangler
2 versions
wrangler@4.124.0
wrangler@4.125.0
@vitest/runner
3 versions
  • root@
    • vitest@4.1.0
      • @vitest/runner@4.1.0

@vitest/runner@4.1.10
@vitest/runner@5.0.0-beta.3
@vitest/snapshot
2 versions
  • root@
    • vitest@4.1.0
      • @vitest/snapshot@4.1.0

@vitest/snapshot@4.1.10
cjs-module-lexer
2 versions
cjs-module-lexer@1.2.3
cjs-module-lexer@2.2.0
@vitest/expect
2 versions
  • root@
    • vitest@4.1.0
      • @vitest/expect@4.1.0

@vitest/expect@4.1.10
@vitest/spy
3 versions
  • root@
    • vitest@4.1.0
      • @vitest/expect@4.1.0
        • @vitest/spy@4.1.0

@vitest/spy@4.1.10
@vitest/spy@5.0.0-beta.3
@vitest/utils
3 versions
  • root@
    • vitest@4.1.0
      • @vitest/expect@4.1.0
        • @vitest/utils@4.1.0

@vitest/utils@4.1.10
@vitest/utils@5.0.0-beta.3
@vitest/mocker
3 versions
  • root@
    • vitest@4.1.0
      • @vitest/mocker@4.1.0

@vitest/mocker@4.1.10
@vitest/mocker@5.0.0-beta.3
@vitest/pretty-format
3 versions
  • root@
    • vitest@4.1.0
      • @vitest/expect@4.1.0
        • @vitest/utils@4.1.0
          • @vitest/pretty-format@4.1.0

@vitest/pretty-format@4.1.10
@vitest/pretty-format@5.0.0-beta.3
@cloudflare/workerd-darwin-64
2 versions
@cloudflare/workerd-darwin-64@1.20260815.1
@cloudflare/workerd-darwin-64@1.20260820.1
@cloudflare/workerd-darwin-arm64
2 versions
@cloudflare/workerd-darwin-arm64@1.20260815.1
@cloudflare/workerd-darwin-arm64@1.20260820.1
@cloudflare/workerd-linux-64
2 versions
@cloudflare/workerd-linux-64@1.20260815.1
@cloudflare/workerd-linux-64@1.20260820.1
@cloudflare/workerd-linux-arm64
2 versions
@cloudflare/workerd-linux-arm64@1.20260815.1
@cloudflare/workerd-linux-arm64@1.20260820.1
@cloudflare/workerd-windows-64
2 versions
@cloudflare/workerd-windows-64@1.20260815.1
@cloudflare/workerd-windows-64@1.20260820.1

💡 To find out what depends on a specific package, run: pnpm -r why example-package

📊 Dependency Size Changes

Warning

This PR adds 221.5 MB of new dependencies, which exceeds the threshold of 100 kB.

📦 Package 📏 Size
@cloudflare/workerd-linux-64@1.20260815.1 150.9 MB
miniflare@5.20260815.0-alpha 26.3 MB
wrangler@4.124.0 24.5 MB
@cloudflare/vitest-pool-workers@0.22.0 7.4 MB
workerd@1.20260815.1 5 MB
zod@4.4.3 4.6 MB
vitest@4.1.10 1.9 MB
@vitest/runner@4.1.10 193.9 kB
@vitest/mocker@4.1.10 187.4 kB
@vitest/utils@4.1.10 168.2 kB
cjs-module-lexer@1.2.3 139.4 kB
@vitest/expect@4.1.10 106.8 kB
@vitest/snapshot@4.1.10 59.3 kB
@vitest/pretty-format@4.1.10 49.8 kB
@vitest/spy@4.1.10 37.4 kB

Total size change: 221.5 MB

The @cloudflare/vitest-pool-workers test harness is only used by the
vitest-actions fixture, which knip treats as its own workspace. Declaring
the pool deps there instead of the adapter package keeps knip's unused
dependency check clean.
An earlier install experiment left vite@8.2.2 in the lockfile, which split
the vite module instance seen by examples/with-vitest: its vitest@5.0.0-beta
resolved against vite 8.2.2 while astro resolved 8.2.1, so the
vitest/config type augmentation no longer applied and astro check failed
on the example's vitest.config.ts (ts2353 'test' does not exist).
Restoring the base lockfile and reinstalling re-resolved everything back
onto vite 8.2.1 with only the new vitest pool harness deps added.
@matthewp
matthewp marked this pull request as ready for review September 8, 2026 22:21
@ematipico
ematipico merged commit 2fc7ce9 into main Sep 9, 2026
30 checks passed
@ematipico
ematipico deleted the fix/17906-actions-cf-vitest-wasm branch September 9, 2026 12:15
@astrobot-houston astrobot-houston mentioned this pull request Sep 9, 2026
dadezzz pushed a commit to dadezzz/university_notes that referenced this pull request Sep 20, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [astro](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/astro)) | [`7.3.2` → `7.3.3`](https://renovatebot.com/diffs/npm/astro/7.3.2/7.3.3) | ![age](https://developer.mend.io/api/mc/badges/age/npm/astro/7.3.3?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/astro/7.3.2/7.3.3?slim=true) |

---

### Release Notes

<details>
<summary>withastro/astro (astro)</summary>

### [`v7.3.3`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#733)

[Compare Source](https://github.com/withastro/astro/compare/astro@7.3.2...astro@7.3.3)

##### Patch Changes

- [#&#8203;17651](withastro/astro#17651) [`504333c`](withastro/astro@504333c) Thanks [@&#8203;sxzz](https://github.com/sxzz)! - Refactors internal version handling to use a smaller, ESM-native dependency

- [#&#8203;17942](withastro/astro#17942) [`0bc5715`](withastro/astro@0bc5715) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Returns appropriate 400 and 404 responses from the image endpoint for invalid and missing local image paths

- [#&#8203;17700](withastro/astro#17700) [`b2222fc`](withastro/astro@b2222fc) Thanks [@&#8203;winklemad](https://github.com/winklemad)! - Fixes `Astro.preferredLocaleList` returning an empty list when a locale is configured with the object form (`{ path, codes }`) and the browser sends the code with different casing or an underscore, such as `en-US` matching a configured `en-us`

- [#&#8203;17941](withastro/astro#17941) [`394ff79`](withastro/astro@394ff79) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Fixes `astro preview --ignore-lock` (and `astro dev --ignore-lock`) being refused when run from an AI agent environment. The flag now starts the server in the foreground instead of erroring, since agent detection only inferred background mode and was never explicitly requested. An explicit `--background` combined with `--ignore-lock` still errors.

- [#&#8203;17928](withastro/astro#17928) [`3277927`](withastro/astro@3277927) Thanks [@&#8203;ArmandPhilippot](https://github.com/ArmandPhilippot)! - Fixes TypeScript autocompletion for `getImage()` to suggest all available predefined options.

- [#&#8203;17928](withastro/astro#17928) [`3277927`](withastro/astro@3277927) Thanks [@&#8203;ArmandPhilippot](https://github.com/ArmandPhilippot)! - Fixes a type error in `getImage()` options that allowed passing both `widths` and `densities` at the same time.

- [#&#8203;17857](withastro/astro#17857) [`2637ed1`](withastro/astro@2637ed1) Thanks [@&#8203;Princesseuh](https://github.com/Princesseuh)! - Improves rendering performance

- [#&#8203;17943](withastro/astro#17943) [`2fc7ce9`](withastro/astro@2fc7ce9) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Fixes a WebAssembly error when importing `astro:actions` in tests that run under `@cloudflare/vitest-pool-workers`

- [#&#8203;18018](withastro/astro#18018) [`1b5a234`](withastro/astro@1b5a234) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes trailing-slash redirect response body pointing to the incoming URL instead of the redirect target. The `location` header was correct, but the HTML body (`<meta http-equiv="refresh">`, `<title>`, and `<a>` tag) contained the original request path without the trailing-slash correction or query string.

- [#&#8203;17905](withastro/astro#17905) [`eaf70fa`](withastro/astro@eaf70fa) Thanks [@&#8203;SudoDevStudio](https://github.com/SudoDevStudio)! - Fixes custom dev toolbar apps losing their UI after client-side navigation with `<ClientRouter />`.

- [#&#8203;18011](withastro/astro#18011) [`558b301`](withastro/astro@558b301) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes prerendered Cloudflare pages rendering as `[object Object]` when `nodejs_compat` is enabled in `wrangler.toml`

- [#&#8203;17944](withastro/astro#17944) [`ba08e35`](withastro/astro@ba08e35) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Fixes a regression in `astro dev` where writes outside the module graph (for example, `@astrojs/cloudflare`'s `.wrangler/state` files) invalidated the middleware on every request, causing repeated SSR reloads. Such writes no longer invalidate the middleware.

- [#&#8203;17531](withastro/astro#17531) [`ae837db`](withastro/astro@ae837db) Thanks [@&#8203;danilloestrela](https://github.com/danilloestrela)! - Updates `svgo` to `4.0.2` to resolve a security advisory

- [#&#8203;17953](withastro/astro#17953) [`dbbf10e`](withastro/astro@dbbf10e) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes a one-time page reload shortly after the first load on cold dev-server starts when a project has framework components imported from MDX content entries. MDX files are now included in the dev dependency pre-bundling scan, so their framework dependencies are bundled up front instead of being discovered (and reloaded for) at runtime.

- [#&#8203;17955](withastro/astro#17955) [`4e8ad9a`](withastro/astro@4e8ad9a) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Improves dev server startup time. The content config and dev server app module graphs now begin compiling during server creation without blocking the server from listening. Request handling waits for the shared setup result when needed, cutting `astro dev` ready time by roughly a third on projects with a content config.

- [#&#8203;17960](withastro/astro#17960) [`9838049`](withastro/astro@9838049) Thanks [@&#8203;Chy-Zaber-Bin-Zahid](https://github.com/Chy-Zaber-Bin-Zahid)! - Improves the diagnostics of some Astro errors.

- [#&#8203;17998](withastro/astro#17998) [`0e5478d`](withastro/astro@0e5478d) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes SVG `<style>` elements nested inside `<defs>` or other container elements not being hashed for CSP

- [#&#8203;17994](withastro/astro#17994) [`80f9f1d`](withastro/astro@80f9f1d) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes `experimental.incrementalBuild` restoring pages with stale CSS after a preprocessor partial changes or missing original images referenced by restored pages

- [#&#8203;17889](withastro/astro#17889) [`8ae6b46`](withastro/astro@8ae6b46) Thanks [@&#8203;ajfAfg](https://github.com/ajfAfg)! - Fixes a bug where the dev server stripped the configured `base` from URLs that only share a prefix with it. With `base: '/s'`, requests to `/src/...` were rewritten to `/rc/...` and failed, breaking those pages during development.

- [#&#8203;17980](withastro/astro#17980) [`cfccafa`](withastro/astro@cfccafa) Thanks [@&#8203;gameroman](https://github.com/gameroman)! - Improves JSDoc for fonts api

- [#&#8203;17953](withastro/astro#17953) [`dbbf10e`](withastro/astro@dbbf10e) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes CSS HMR for framework components rendered through content entries after `ClientRouter` navigation

- [#&#8203;17970](withastro/astro#17970) [`0b4dc3a`](withastro/astro@0b4dc3a) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Improves serialization of transition animation values in generated CSS

- [#&#8203;17999](withastro/astro#17999) [`30ef3cb`](withastro/astro@30ef3cb) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes content collection HMR not updating prerendered pages when an adapter enables a separate prerender environment (e.g. `@astrojs/cloudflare` with `prerenderEnvironment: 'node'`)

- [#&#8203;18002](withastro/astro#18002) [`312ab49`](withastro/astro@312ab49) Thanks [@&#8203;shoutoutuoadi325](https://github.com/shoutoutuoadi325)! - Fixes redirect targets being corrupted when a dynamic route parameter value contains `$` replacement patterns like `$&`

- [#&#8203;17937](withastro/astro#17937) [`e294953`](withastro/astro@e294953) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Fixes a bug where the `glob()` content loader kept stale entries in the data store after the last file in a collection was deleted. Empty collections are now pruned correctly, and the file watcher is registered in dev so the first file added to an empty collection is picked up without a restart.

- [#&#8203;17945](withastro/astro#17945) [`750b4db`](withastro/astro@750b4db) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Pre-bundles renderer server entrypoints and the default console logger during dev so they are included in the initial optimization pass, preventing a mid-request re-optimization that could crash the dev server on Cloudflare (workerd).

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xMDMuMiIsInVwZGF0ZWRJblZlciI6IjQ0LjEwMy4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants