fix(turbopack): use file persistence on wasm - #98613
Draft
sokra wants to merge 1 commit into
Draft
Conversation
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>
Contributor
Tests PassedCommit: f155214 |
sokra
added this pull request to stack #97861
September 13, 2026 17:21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #98495.
What?
Enable Turbo Tasks persistence on
wasm32by 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
memmap2requires. KeepingAccessMode::Mmapavailable 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::Mmapand its mmap-only implementation paths are compile-time excluded on wasm, so selecting mmap there is impossible rather than a runtime error.AccessMode::Filebecomes 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_storagepersistence 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-threadscargo clippy -p turbo-persistence -p turbo-tasks-backend --lib --tests --target wasm32-wasip1-threads -- -D warningscargo test -p turbo-tasks-backend --lib --target wasm32-wasip1-threads -- kv_backing_storage::teststurbo-persistenceandturbo-tasks-backendfocused testscargo fmt --check