cowasm
cowasm copied to clipboard
wasi-js: warnings are printed to stdout
Hello,
I just switched from wasmer to wasi-js
in the WasiCaml project (https://github.com/remixlabs/wasicaml). There are a lot of scripts running WASI-fied wasm code, and some of them also write to stdout. I found in the stdout of one script the string
cpu waiting for stdin: please define a way to sleep!
which causes the further build to fail. Obviously, this warning is from wasi-js
and printed with console.log
which goes to stdout. For scripting, this is very unfortunate - whereas messages in stderr are typically no problem. Can you switch to console.warn
or console.error
instead?
Btw, thanks for picking the code up and maintaining it.
Looks like that there is a workaround: assign
console.log = console.error
just before starting wasm.
Another remark: I got this warning when redirecting stdin to a file. The warning seems to be fairly inappropriate in this case - files never block. It might be better to move the warning a few lines downwards, where you call shortPause
.
Can you send me a PR changing to warn? I'm happy to quickly review it, merge it, and update the npm package.
And I agree with you and see how that output could be annoying. It was something I put in to avoid problems with my interactive REPL work (for https://cowasm.org and https://cowasm.sh) that builds on this. However, it's fine to change it to console.warn, console.error, or even remove it, at at this point.
Thanks for using wasi-js!
Here's the relevant code: https://github.com/sagemathinc/cowasm/blob/main/core/wasi-js/src/wasi.ts#L950
I'll take a look later today.