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

hurfmt: panics when broken pipe #3661

Closed
jcamiel opened this issue Jan 29, 2025 · 1 comment · Fixed by #3701
Closed

hurfmt: panics when broken pipe #3661

jcamiel opened this issue Jan 29, 2025 · 1 comment · Fixed by #3701
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@jcamiel
Copy link
Collaborator

jcamiel commented Jan 29, 2025

hurlfmt is panicking when pipe is broken:

$ echo 'GET https://hurl.dev' | hurlfmt --out json | aaa
zsh: command not found: aaa
thread 'main' panicked at packages/hurlfmt/src/main.rs:138:18:
writing bytes to console: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Panicking is here =>

file.write_all(bytes.as_slice())
.expect("writing bytes to file");

Compare with Hurl:

$ echo 'GET https://hurl.dev' | hurl | aaa                     
zsh: command not found: aaa
error: IO Error
  --> -:1:1
   |
 1 | GET https://hurl.dev
   | ^ Broken pipe (os error 32)
   |

hurlfmt should exit with an error message and a status code != 0.

@jcamiel jcamiel added bug Something isn't working good first issue Good for newcomers labels Jan 29, 2025
@ikorason
Copy link
Contributor

ikorason commented Feb 5, 2025

Hi, I created the PR #3701, not sure if its a good fix but also update the original bug description, because the panic is occurring at

handle
.write_all(bytes.as_slice())
.expect("writing bytes to console");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants