Open gramakri opened 5 months ago
Unfortunately, this timeout error doens't happen always but most of the time. I debugged this a bit and the second callback error that causes the message is:
Error: aborted
at connResetException (node:internal/errors:717:14)
at TLSSocket.socketCloseListener (node:_http_client:462:19)
at TLSSocket.emit (node:events:525:35)
at node:net:322:12
at TCP.done (node:_tls_wrap:588:7) {
code: 'ECONNRESET'
}
The timeout() code calls abort which maybe somehow ends up with an 'error' event with reset ? This matches the behavior outlined in https://nodejs.org/api/http.html#httprequesturl-options-callback which says:
In the case of a premature connection close after the response is received, the following events will be emitted in the following order:
'socket'
'response'
'data' any number of times, on the res object
(connection closed here)
'aborted' on the res object
'error' on the res object with an error with message 'Error: aborted' and code 'ECONNRESET'
'close'
'close' on the res object
Describe the bug
Node.js version: v18.16.0
OS version: ubuntu 22.04
Description: When a request aborts with a timeout, it calls the callback twice resulting in a message being printed on the console "superagent: double callback bug"
Expected behavior
Should not print the console message and should not call the callback twice
Code to reproduce
Output (with DEBUG=*) :
Checklist