-
Notifications
You must be signed in to change notification settings - Fork 88
Open
Labels
Description
The following component code does not seem to work in a browser context (and may not in a NodeJS context either) when transpiled:
import { getDirectories } from "wasi:filesystem/[email protected]";
export const test = {
run() {
const preopens = getDirectories();
if (preopens.length === 0) { throw "ERROR: no preopens"; }
const dirDescriptor = preopens[0][0];
const newFileRes = dirDescriptor.openAt(
{symlinkFollow: false},
"output.txt",
{ create: true },
{ write: true },
);
if (newFileRes.tag === "err") {
throw "ERROR: failed to create new file: " + newFileRes.val;
}
const newFileDescriptor = newFileRes.val;
newFileDescriptor.write(new TextEncoder().encode("hello world!"), 0);
const syncRes = newFileDescriptor.sync();
if (syncRes.tag !== "ok") {
throw "ERROR: failed to sync new file to disk: " + syncRes.val;
}
return "SUCCESS: wrote file";
}
}The error that is returned is the following (output from a local test):
[browser] log: expected a string
[browser] log: Stack:
[browser] log: utf8Encode@/tmp/67e786128b1f/sources/initializer.js:66:36
export_test$run@/tmp/67e786128b1f/sources/initializer.js:6288:28
[browser] log:
[browser] log: Redirecting call to abort() to mozalloc_abort
RuntimeError: unreachable
RuntimeError: unreachable
at http://127.0.0.1:34397/transpiled/component.core.wasm:wasm-function[12408]:0x88502e
at http://127.0.0.1:34397/transpiled/component.core.wasm:wasm-function[4500]:0x1aaaac
at tests:p2-shim/test#run (http://127.0.0.1:34397/transpiled/component.core.wasm:wasm-function[12536]:0x89b54f)
at run (http://127.0.0.1:34397/transpiled/component.js:13246:15)
at runTranspiledModuleTest (http://127.0.0.1:34397/index.html:100:27)
at async http://127.0.0.1:34397/index.html:74:4
Ideally after this is fixed, the preview2-shim browser test should be updated to do more than just open a file and should write contents (and maybe read them back) as well.