Skip to content

fix(core): survive WASI hosts without preopened directories - #592

Merged
linroid merged 1 commit into
mainfrom
fix/wasi-no-preopens
Oct 18, 2026
Merged

linroid merged 1 commit into
mainfrom
fix/wasi-no-preopens

Conversation

@linroid

@linroid linroid commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Problem

On main, :library:core:wasmWasiNodeTest fails AwaitFileSelectionTest, and a full run kills the Node process with RuntimeError: dereferencing a null pointer in okio.internal.commonExists.

okio's WasiFileSystem throws IllegalStateException("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

  • platformFileSystem on WasmWasi touches WasiFileSystem once and, if it cannot initialize, falls back to NoPreopensFileSystem: nothing exists and I/O fails with an IOException, as for a path outside every preopen.
  • library/core/build.gradle.kts patches 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 /.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T00:45:11.052257Z 186085e PR opened
ℹ️ 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" or "@codex security review".

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.
@linroid
linroid force-pushed the fix/wasi-no-preopens branch from 186085e to a06300d Compare October 18, 2026 00:42
@linroid
linroid merged commit 823ba97 into main Oct 18, 2026
@linroid
linroid deleted the fix/wasi-no-preopens branch October 18, 2026 00:43

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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