-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
False successfully end of request #8102
Comments
Also tested on v4.4.7 with the same result. |
/cc @bnoordhuis I seem to recall you had answered a similar question before |
The client sees an empty read when the server is killed. You can verify that with strace. curl expects a zero-sized HTTP chunk because it sends Node.js does not raise an error when keep-alive is enabled and the connection is closed before the final zero chunk but you can check if
It's been around for a long time though, it was added when support for trailing HTTP headers was implemented in node.js v0.3.0. Adding doc and test labels. |
Hi, there. I encountered same problem. I'll try
Why Node.js does not raise an error in such situation? It looks reasonable. |
@bnoordhuis thanks for explanation, |
I'm not 100% sure but I think it's for compatibility. Not all HTTP endpoints follow the spec as closely as they should. You could argue, tongue in cheek, that closing the connection without sending the zero chunk is a performance optimization - saves a TCP round-trip! |
Yep.. there are some implementations that have been rather pathological about not properly terminating a chunked stream. While throwing would make sense in theory, it ends up being a bit problematic in practice. |
got it, thanks |
@nodejs/documentation @nodejs/testing |
@nodejs/http |
Hi everybody, May I have a short example of the implementation of the Thanks all! |
Fixes: #8102 PR-URL: #23914 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
Fixes: #8102 PR-URL: #23914 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
Fixes: #8102 PR-URL: #23914 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
Fixes: #8102 PR-URL: #23914 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
Fixes: #8102 PR-URL: #23914 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
Fixes: #8102 PR-URL: #23914 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
Linux robin-master 3.19.0-15-generic #15-Ubuntu SMP Thu Apr 16 23:32:37 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Long client requests ends successfully if data transfer closed for some reason, for example if server lost connectivity or suddenly fall.
For example I have one client Node.js app which make request to server Node.js app to receive a lot of chunks of data. Data transfer lasts for several time and server app falls before request completion.
I expect to get some error on client side to inform me that transfer was not successfully ended, but emits
end
event instead oferror
. So I have a situation when I receive only part of data but don't know about it and think that request successfully ended.Example server send parts of JSON object for ~2 seconds. For test purpose I run following shell command:
timeout 1s node server.js & node client.js
Because data transfer lasts 2 seconds client app receive only part of data but ends with emit
end
handler without any error. May be problem onclientRequest
part of Node.js cause the same trick withcurl
as client side return(18) transfer closed
error.Example of client app:
Example of server app
The text was updated successfully, but these errors were encountered: