Skip to content

fix(turbopack): use file persistence on wasm - #98613

Draft
sokra wants to merge 1 commit into
codex/turbopack-wasm/wasm-runtime-shutdownfrom
codex/turbopack-wasm/wasm-persistence-file-io
Draft

fix(turbopack): use file persistence on wasm#98613
sokra wants to merge 1 commit into
codex/turbopack-wasm/wasm-runtime-shutdownfrom
codex/turbopack-wasm/wasm-persistence-file-io

Conversation

@sokra

@sokra sokra commented Sep 13, 2026

Copy link
Copy Markdown
Member

Stacked on #98495.

What?

Enable Turbo Tasks persistence on wasm32 by making file I/O the only available persistence access mode on that target. The persistence tests that previously stopped at the unsupported mmap implementation now run against the file-backed path.

Why?

WASI does not provide the memory-mapping support that memmap2 requires. Keeping AccessMode::Mmap available on wasm would leave a configuration that compiles but fails at runtime, and would require every JavaScript loader or test host to know about an internal environment-variable override.

How?

AccessMode::Mmap and its mmap-only implementation paths are compile-time excluded on wasm, so selecting mmap there is impossible rather than a runtime error. AccessMode::File becomes the only and default wasm mode. Native targets retain both modes, including the existing environment-variable behavior and mmap default.

Test-only code uses the file-backed equivalent where an mmap mode cannot exist, allowing the three kv_backing_storage persistence tests to run on WASI without weakening their surrounding behavioral assertions.

This does not claim end-to-end wasm persistence yet: the wasm binding still needs runtime initialization and package integration before a real Turbopack build can consume this path.

Testing

  • cargo check -p turbo-persistence --target wasm32-wasip1-threads
  • cargo clippy -p turbo-persistence -p turbo-tasks-backend --lib --tests --target wasm32-wasip1-threads -- -D warnings
  • cargo test -p turbo-tasks-backend --lib --target wasm32-wasip1-threads -- kv_backing_storage::tests
  • Native turbo-persistence and turbo-tasks-backend focused tests
  • cargo fmt --check

Compile AccessMode::Mmap and its code paths only on targets that support memory mapping. WASI now defaults structurally to the file-backed access mode added in #97873, allowing the three kv_backing_storage persistence tests to run instead of being skipped.

Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
Co-authored-by: Luke Sandberg <210140+lukesandberg@users.noreply.github.com>
@github-actions

github-actions Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Tests Passed

Commit: f155214

@sokra
sokra added this pull request to stack #97861 September 13, 2026 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant