Skip to content
New issue

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

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

Already on GitHub? # to your account

[bug] Missing newline character for ("on", "data") callback on js api #6388

Closed
GabrieleRoncolato opened this issue Mar 2, 2023 · 4 comments
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@GabrieleRoncolato
Copy link

GabrieleRoncolato commented Mar 2, 2023

Describe the bug

I'm experiencing an issue with the on data callback for the stdout pipeline when spawning a child process.
The child process spawned by Tauri is written in C: it prints a string which might terminate with a newline character or not, and a fflush is called right after this print.
The issue is that Tauri never includes the newline character when the on data listener is called, but I need to know if that newline character was present or not in the stdout.

Reproduction

I have prepared a Tauri application to showcase this error: https://github.com/TALCo-Team/tauri-issue-newline-stdout

In order to reproduce the error, simply build and run the test application and observe the results reported inside the main page: the stdout outputs of the executed program will be missing the expected newline characters.
You can also check the C source code and try to run the launched executable using the shell instead: you'll see that the newline characters should indeed be present.

Expected behavior

The Tauri interface should be able to report all newline characters from the stdout of its child processes, but it looks like all trailing newline characters are instead cutoff.

Platform and versions

yarn tauri dev

The test application has been run on Ubuntu 20.04 and Windows 10 using the latest available version for Tauri, the issue only seems to happen on Ubuntu 20.04.

Stack trace

No response

Additional context

No response

@GabrieleRoncolato GabrieleRoncolato added status: needs triage This issue needs to triage, applied to new issues type: bug labels Mar 2, 2023
@amrbashir
Copy link
Member

Please provide the needed information especially the reproduction, I will reopen the issue once a reproduction is submitted.

@amrbashir amrbashir closed this as not planned Won't fix, can't repro, duplicate, stale Mar 2, 2023
@GabrieleRoncolato
Copy link
Author

I have updated the issue by providing a link to a test application which showcases the error

@amrbashir amrbashir reopened this Mar 17, 2023
@amrbashir
Copy link
Member

So this is actually the intended behavior, you get each line separately, so you can process each line as it comes, if you want to concatenate them and display them, you need to add the new line in your code.

However, there is not the case on Windows and I will try to fix this to make it consistent.

@amrbashir
Copy link
Member

amrbashir commented Mar 21, 2023

Diving deeper into this issue, I think the intended behavior should be to include \n in the line according to this https://doc.rust-lang.org/std/io/trait.BufRead.html#method.read_line which means it is broken on both windows and unix.

lucasfernog added a commit that referenced this issue Aug 8, 2023
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
fix(tauri-utils): include `\n` in `io::read_line`, closes #6388
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

No branches or pull requests

2 participants