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

error handling on stdout - pipe buffer #59

Closed
patrykcieszkowski opened this issue Jun 15, 2022 · 7 comments · Fixed by #67
Closed

error handling on stdout - pipe buffer #59

patrykcieszkowski opened this issue Jun 15, 2022 · 7 comments · Fixed by #67
Labels

Comments

@patrykcieszkowski
Copy link
Contributor

patrykcieszkowski commented Jun 15, 2022

Pipe buffer was delaying progress updates, and on some commands - prevented them from appearing at all. I ended up using script cmd to disable it, but it merges stdout and stderr outputs together. We have to either find a better solution or to somehow distinguish between the desired output and the error.

@patrykcieszkowski
Copy link
Contributor Author

patrykcieszkowski commented Jun 24, 2022

We could print errors to a log file, and read them directly from the file. This would stop errors from appearing in stdout.

ping -4 -c 3 -i 0.2 -w 15 -n br.debian.org 2>/tmp/errorlog

Of course, every measurement would need to have its own errorlog file.

Alternativelly, we could attach a prefix to stderr and distinguish errors from the actual output that way:

ping -4 -c 3 -i 0.2 -w 15 -n br.debian.org 2> >(sed 's/^/error: /')

@patrykcieszkowski
Copy link
Contributor Author

Here's what I found, and I actually don't understand why that is:

If from within stdout handler, you call cmd.stderr?.emit('error', data), the execa is going to fail and will report an error. However, the error won't be reported under stderr value, but under stdout.

@patrykcieszkowski
Copy link
Contributor Author

Alternativelly, we could attach a prefix to stderr and distinguish errors from the actual output that way:

As it turns out, when modifying stderr input, the result is not always present. It's especially noticible if you run test on multuple probes at once. I don't know why.

@patrykcieszkowski
Copy link
Contributor Author

going back to unbuffer seems like the only solution; it captures the exit code, which makes errors resolve as usual.

@jimaek
Copy link
Member

jimaek commented Jun 25, 2022

Ok well let's do it then. Better now than after going live

@patrykcieszkowski
Copy link
Contributor Author

patrykcieszkowski commented Jun 27, 2022

mtr always ends with exit code 0 when requested with non-UI output type. Seems like we gonna have to rely on manual handling at some cases.

traviscross/mtr#294

@github-actions
Copy link

github-actions bot commented Jul 4, 2022

🎉 This issue has been resolved in version 0.7.4 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

2 participants