Repository navigation
fix(core): survive WASI hosts without preopened directories - #592
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
okio's WasiFileSystem throws while initializing when the host preopens no directories, and every later access traps the module, which crashed the wasmWasi test process. Fall back to a file system where nothing exists, and preopen / for the wasmWasi test runner, whose tests write real files.
186085e to
a06300d
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 186085e264
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| /** A row's key in the list: a folder's path, which no file id starts with, or the file's id. */ | ||
| private fun rowKey(node: TorrentNode): String = | ||
| if (node is TorrentNode.Folder) "/${node.path}" else node.fileIds.single() |
There was a problem hiding this comment.
Namespace folder and file row keys separately
When a custom source uses a valid file ID such as /extras and also exposes an extras folder, this function assigns both rows the key /extras. SourceFile.id is only required to be unique within the source and has no restriction against a leading slash, so Compose's LazyColumn will reject the duplicate key when both rows are visible. Prefix both folder and file keys with distinct type markers rather than assuming file IDs cannot start with /.
Useful? React with 👍 / 👎.
Problem
On main,
:library:core:wasmWasiNodeTestfailsAwaitFileSelectionTest, and a full run kills the Node process withRuntimeError: dereferencing a null pointerinokio.internal.commonExists.okio's
WasiFileSystemthrowsIllegalStateException("no preopens")from its initializer when the WASI host preopens no directories, which Kotlin's generated Node test runner never does. The first access fails (a download fails, so a test sees no run); every later access reads the half-built object and traps the whole module. Any WASI host without preopens would crash the engine the same way.Fix
platformFileSystemon WasmWasi touchesWasiFileSystemonce and, if it cannot initialize, falls back toNoPreopensFileSystem: nothing exists and I/O fails with anIOException, as for a path outside every preopen.library/core/build.gradle.ktspatches the generated wasmWasi test runner after linking to preopen/, since the tests write real files (73 failed with the fallback alone). It fails the build if the runner's format changes.Testing
./gradlew :library:core:wasmWasiNodeTest :library:core:jvmTest :library:core:jsNodeTest: wasmWasi 547/547, JVM 599/599, JS 547/547.Note: CI does not run
wasmWasiNodeTest, and no test covers the no-preopens fallback now that tests preopen/.