fix(wasm): avoid panic in split_paths on wasm#1064
Merged
Conversation
Test Results 3 files 32 suites 15m 34s ⏱️ Results for commit 3a9790c. |
Public API changes for crate: brush-coreAdded itemsPerformance Benchmark Report
Code Coverage Report: Only Changed Files listed
Minimum allowed coverage is Test Summary: bash-completion test suite
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR mitigates a runtime panic on some WASM targets by routing PATH splitting through brush-core’s platform abstraction layer (crate::sys) and providing a WASM-safe fallback implementation.
Changes:
- Introduces
crate::sys::fs::split_pathswith platform-specific implementations (Unix/Windows delegate tostd::env::split_paths, WASM uses a:split). - Updates shell PATH searching to use
crate::sys::fs::split_pathsinstead of callingstd::env::split_pathsdirectly. - Switches Windows/WASM platform modules to provide a real
fsmodule rather than re-exporting the stub module directly.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| brush-core/src/sys/windows/fs.rs | Adds Windows split_paths wrapper delegating to std::env::split_paths. |
| brush-core/src/sys/windows.rs | Uses a concrete fs module so split_paths can be provided on Windows. |
| brush-core/src/sys/wasm/mod.rs | Uses a concrete fs module so split_paths can be provided on WASM. |
| brush-core/src/sys/wasm/fs.rs | Adds WASM split_paths implementation (currently allocates and string-converts). |
| brush-core/src/sys/unix/fs.rs | Adds Unix split_paths wrapper and routes existing code through it. |
| brush-core/src/shell/fs.rs | Switches PATH searching to use crate::sys::fs::split_paths. |
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.
std::env::split_pathspanics on some WASM platforms. For now, let's route calls to it through thesysmodule and provide an alternate implementation for some targets.