Skip to content

Commit bf2be52

Browse files
robert3005claude
andauthored
Fix wasm32 build by gating MultiFileSession on non-wasm targets (#8612)
## Rationale for this change The `MultiFileSession` holds a `moka` cache that reads `std::time::Instant::now()` during construction. The `Instant` type is unsupported on `wasm32` targets and panics with "time not implemented on this platform". Since multi-file scanning is not available on wasm anyway, this change gates the `MultiFileSession` registration behind a `#[cfg(not(target_arch = "wasm32"))]` guard to allow the wasm32 build to succeed. ## What changes are included in this PR? Added a `#[cfg(not(target_arch = "wasm32"))]` attribute to the `MultiFileSession` registration in `vortex/src/lib.rs` to prevent instantiation of the session on wasm32 targets where `std::time::Instant` is not available. ## What APIs are changed? Are there any user-facing changes? No public APIs are changed. This is a build fix that prevents a panic on wasm32 targets. Multi-file scanning functionality remains unavailable on wasm, as it was before. https://claude.ai/code/session_01P5VUBo8DhakxhhF1Ux2Kte --------- Signed-off-by: Robert <robert@spiraldb.com> Signed-off-by: Robert Kruszewski <github@robertk.io> Co-authored-by: Claude <noreply@anthropic.com>
1 parent 88222ac commit bf2be52

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

vortex/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,11 @@ impl VortexSessionDefault for VortexSession {
301301
.with::<MemorySession>()
302302
.with::<RuntimeSession>();
303303

304-
#[cfg(feature = "files")]
304+
// `MultiFileSession` holds a `moka` cache whose clock reads `std::time::Instant::now()`
305+
// when constructed. `Instant` is unsupported on `wasm32` and panics with "time not
306+
// implemented on this platform". Multi-file scanning is not available on wasm anyway, so
307+
// only register this session variable on non-wasm targets.
308+
#[cfg(all(feature = "files", not(target_arch = "wasm32")))]
305309
let session = {
306310
let session = session.with::<file::multi::MultiFileSession>();
307311
file::register_default_encodings(&session);

0 commit comments

Comments
 (0)