-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
Not possible to write multi-line errors to console #492
Comments
This is one of the limitations in the WASI syscall interface. The fd_write syscall used as the underlying mechanism of
Our current way results:
However, if we call console.error for each fd_write call, it results in:
Unless we have a way to write message in the last line without newline, we can't avoid such chopped up messages. Therefore, if you really want to control when the message should be flushed, you need to use console API directly instead of relying on WASI-backed printing methods like |
Understood! Do you think it would be an option to buffer logs a single render tick and then combine any entries with the same stack trace before flushing to the web console? Or would that be problematic in its own right? Feel free to close if it's completely unreasonable to fix 😄 We've customized our error reporter to report directly to the console, but wanted to flag this if it was possible to address in carton itself. |
Interesting idea. It still potentially chops up messages when printing across frames (see below example), but I think it should solve the problem in 99% cases. print("Hello, ", terminator: "")
await JSPromise.resolve(.undefined).value
print("Swift") I'll make time to explore how other communities address this problem later. |
It seems that carton feeds each
onStderrLine
result to its ownconsole.error
, so if a Swift app writes multiple lines at once tostderr
to format things, rather than emitting a single browser error with the formatted message, the browser emits a unique error per line:The text was updated successfully, but these errors were encountered: