Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

console.error doesn't send output to STDERR, but to STDOUT #2585

Open
mariusa opened this issue Dec 4, 2022 · 5 comments
Open

console.error doesn't send output to STDERR, but to STDOUT #2585

mariusa opened this issue Dec 4, 2022 · 5 comments

Comments

@mariusa
Copy link

mariusa commented Dec 4, 2022

console.error doesn't send output to STDERR, but to STDOUT, prepended with string "Error:"

console.error should send output to STDERR, similar to Console from as-wasi

@CountBleck
Copy link
Member

Under what environment are you running the module? More information would be helpful.

@mariusa
Copy link
Author

mariusa commented Dec 4, 2022

For example, linux bash:

wasmtime test.wasm > out.txt 2>error.txt

These 2 files are correctly populated for Console.error / Console.log, but for built-in console, all output goes go out.txt, while error.txt is empty.

@dcodeIO
Copy link
Member

dcodeIO commented Dec 6, 2022

Relevant code section appears to be here:

https://github.com/AssemblyScript/wasi-shim/blob/0d84fc60e493c8dc2750db5d5faffd240401e469/assembly/wasi_console.ts#L39-L51

@mariusa
Copy link
Author

mariusa commented Dec 6, 2022

@dcodeIO right.

Also, the strings specified by programmer shouldn't be changed (eg prepend "Error:"). This output might be parsed by something else. We can concatenate strings ourselves, if that's what we need.

@github-actions github-actions bot added the stale label Jan 5, 2023
@AssemblyScript AssemblyScript deleted a comment from github-actions bot Jan 5, 2023
CountBleck added a commit to CountBleck/wasi-shim that referenced this issue May 21, 2023
Node.js has the same behavior (and it makes sense). Now, all functions
use the correct stream.

Fixes AssemblyScript/assemblyscript#2585.
@CountBleck
Copy link
Member

This output might be parsed by something else.

@mariusa why not parse around those prepended strings then? If finer-grained control is needed, process.stderr.write("foo\n") can be used. I'd think console.{log,error,info,debug,warn}()is used for quick-and-dirty debugging, and the prefixes don't really matter in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants