request / tunnel-agent

HTTP proxy tunneling agent. Formerly part of mikeal/request, now a standalone module.
Apache License 2.0
117 stars 105 forks source link

Real error code is overwritten with ECONNRESET #19

Open rhalff opened 8 years ago

rhalff commented 8 years ago

I notice the real error code is overwritten with ECONNRESET.

https://github.com/request/tunnel-agent/blob/master/index.js#L177

The real error code is contained in cause.code and not passed along.

In my case the error code is ECONNREFUSED

{ Error: tunneling socket could not be established, cause=connect ECONNREFUSED 127.0.0.1:42963
    at ClientRequest.onError (node_modules/tunnel-agent/index.js:177:17)
    at ClientRequest.g (events.js:286:16)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at Socket.socketErrorListener (_http_client.js:306:9)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at emitErrorNT (net.js:1272:8)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9) code: 'ECONNRESET' }