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

Can we improve the "Failed writing body" error message? #5594

Closed
coinhubs opened this issue Jun 23, 2020 · 15 comments
Closed

Can we improve the "Failed writing body" error message? #5594

coinhubs opened this issue Jun 23, 2020 · 15 comments

Comments

@coinhubs
Copy link

Could the "(23) Failed writing body" be more descriptive? Was wondering if this 23 ENFILE?
From reading online it looks like the pipe might have been closed too soon, so maybe that could be clearer
https://stackoverflow.com/questions/16703647/why-does-curl-return-error-23-failed-writing-body

Sorry I'm not using a dev build, I saw there was a similar fix in this area in Feb 2020.

I did this

$ curl -Is https://www.google.com |head -1
HTTP/2 200
(23) Failed writing body

I expected the following

HTTP/2 200

curl/libcurl version

[curl -V output]
$ curl -V
curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3
Release-Date: 2020-01-0

operating system

Latest Ubuntu LTS

@coinhubs
Copy link
Author

#2030 sounds similar

@bagder
Copy link
Member

bagder commented Jun 23, 2020

The code that writes the error message has no clue where the write was done so it can't say "pipe" because it could've been a buffer or a file.

Would Failed writing response data to the intended destination be any better?

@bagder bagder changed the title (23) Failed writing body Can we improve the "Failed writing body" error message? Jun 23, 2020
@coinhubs
Copy link
Author

The code that writes the error message has no clue where the write was done so it can't say "pipe" because it could've been a buffer or a file.

Would Failed writing response data to the intended destination be any better?

Hello Badger, Yes, that sure sounds better, even better is to put Curl in the message. Saw saw this on a terminal, had no idea where it came from. Maybe "Curl failed to write data to destination" ?

May I ask, what is the exact writing error, EIO?

@bagder
Copy link
Member

bagder commented Jun 23, 2020

even better is to put Curl in the message

We can't do that, this is libcurl creating the error and libcurl is also used by hundreds of other applications than curl.

But really, curl already prefixes the error message with curl:, it doesn't look the way you showed it. See below for 7.68.0 and 7.71.0-DEV both show it when I try this:

$ curl localhost/512M | head -c 1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0  512M    0  127k    0     0   124M      0  0:00:04 --:--:--  0:00:04  124M
curl: (23) Failed writing body (250 != 16384)

@bagder
Copy link
Member

bagder commented Jun 23, 2020

what is the exact writing error, EIO

In your particular use case it is fwrite() returning an error, but this error message is more general and the failed writing could also be a callback returning an error etc.

@bagder
Copy link
Member

bagder commented Jun 23, 2020

Is this better?

./src/curl localhost/512M | head -c 1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0  512M    0 65286    0     0  31.1M      0  0:00:16 --:--:--  0:00:16 31.1M
curl: (23) Failed writing response data to the destination

bagder added a commit that referenced this issue Jun 23, 2020
Replace "Failed writing body (X != Y)" with "Failed writing response
data to the destination"

Reported-by: coinhubs on github
Fixes #5594
@coinhubs
Copy link
Author

Hello badger
Many thanks for working on this so quickly.

Yes, this looks better. My only feedback is in relation to the English. "the" is not necessary in the message. "Failure" is the way we would write in English. I'd probably leave out "data" as well

ie. "curl: Failure writing output to destination"

Any idea what the error code 23 is?

@bagder
Copy link
Member

bagder commented Jun 23, 2020

All curl error messages are shown like that. The number within parenthesis is the numerical error it returns.

@coinhubs
Copy link
Author

Ah, ok, now I understand CURLE_WRITE_ERROR (23) I read here online:
https://curl.haxx.se/libcurl/c/libcurl-errors.html

I'd be happy to see CURLE_WRITE_ERROR or other error enum. Is that what curl_easy_strerror() returns?

@bagder
Copy link
Member

bagder commented Jun 24, 2020

The error codes from curl, the command line tool, is described in the man page for curl. At the end of it:

       23     Write error. Curl couldn't write data to a local filesystem or similar.

@bagder bagder closed this as completed in 550bcdd Jun 24, 2020
@coinhubs
Copy link
Author

The error codes from curl, the command line tool, is described in the man page for curl. At the end of it:

       23     Write error. Curl couldn't write data to a local filesystem or similar.

Many thanks for your reply.

The difficulty is when the line appears in a log or stdout :

My program output
(23) Failed writing body
Other parts of my program output
Read file index.html

I can't figure-out where that came from, unless it has a "curl" prefix, as it all just went to stdout.
Is there anyway curl could identifyt it self? Generally unix programs output themselvs as the first part of the output line

eg

$ cd missing_dir
bash: cd: missing_dir: No such file or directory

Thank you again for making this change to improve this

@bagder
Copy link
Member

bagder commented Jun 24, 2020

Again: curl does this. Let me show you an example with curl 7.68.0:

$ curl localhost/512M | head -c 1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0  512M    0  127k    0     0   124M      0  0:00:04 --:--:--  0:00:04  124M
curl: (23) Failed writing body (250 != 16384)

@coinhubs
Copy link
Author

Again: curl does this. Let me show you an example with curl 7.68.0:

$ curl localhost/512M | head -c 1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0  512M    0  127k    0     0   124M      0  0:00:04 --:--:--  0:00:04  124M
curl: (23) Failed writing body (250 != 16384)

I see, I'm sure it's a problem in my environment then. Thank you again for your reply. And developing such a useful tool!

@sushanth-hrn
Copy link

image
any idea on how to resolve this?

@bagder
Copy link
Member

bagder commented Jun 6, 2021

Asking support question in an issue we closed a year ago is not the way at least.

@curl curl locked as resolved and limited conversation to collaborators Jun 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging a pull request may close this issue.

3 participants