You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have http client that sends HTTP POST request with quite big payload to upstream haproxy server. This server rejects the request early with 401 Unathorized, does not read the whole request body from client, sends 401 response with 'Connection: close' header. This behavior causes EPIPE on node http client. But the server sends correct response and I need to propagate the response to the client.
How often does it reproduce? Is there a required condition?
Every time against haproxy server which immediately rejects the request with 401 Unauthorized.
What is the expected behavior? Why is that the expected behavior?
The server response should be returned to the client.
What do you see instead?
EPIPE error.
node:events:495
throw er; // Unhandled 'error' event
^
Error: write EPIPE
at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16)
Emitted 'error' event on ClientRequest instance at:
at Socket.socketErrorListener (node:_http_client:501:9)
at Socket.emit (node:events:517:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -32,
code: 'EPIPE',
syscall: 'write'
}
Additional information
I tried to fix this behavior with this code, but occasionally I get empty response, so perhaps there is some problem with my code.
Could please someone check it for correctness and suggest improvements or usage of other mechanism how to achieve the same goal (propagate server response to the client in this scenario).
IMHO I think that this should be fixed within nodejs http/net module itself. In case that server responds early and with Connection: close it is safe to ignore EPIPE error and abort sending the rest of client request body.
The text was updated successfully, but these errors were encountered:
Version
v14+
Platform
Subsystem
net,http
What steps will reproduce the bug?
Hello,
this issue is probably related to these existing issues:
#9085
#12339
#38467
I have http client that sends HTTP POST request with quite big payload to upstream haproxy server. This server rejects the request early with 401 Unathorized, does not read the whole request body from client, sends 401 response with 'Connection: close' header. This behavior causes EPIPE on node http client. But the server sends correct response and I need to propagate the response to the client.
Here is my code without the fix:
How often does it reproduce? Is there a required condition?
Every time against haproxy server which immediately rejects the request with 401 Unauthorized.
What is the expected behavior? Why is that the expected behavior?
The server response should be returned to the client.
What do you see instead?
EPIPE error.
Additional information
I tried to fix this behavior with this code, but occasionally I get empty response, so perhaps there is some problem with my code.
Could please someone check it for correctness and suggest improvements or usage of other mechanism how to achieve the same goal (propagate server response to the client in this scenario).
IMHO I think that this should be fixed within nodejs http/net module itself. In case that server responds early and with
Connection: close
it is safe to ignore EPIPE error and abort sending the rest of client request body.The text was updated successfully, but these errors were encountered: