node-proxy-middleware icon indicating copy to clipboard operation
node-proxy-middleware copied to clipboard

Server manually closed but still getting errors from the proxy

Open binarykitchen opened this issue 10 years ago • 2 comments

I manually closed the express server with server.close(), yet the proxy throws an error. I guess the proxy is not listening to the server's shutdown process?

Error: connect ECONNREFUSED
    at errnoException (net.js:905:11)
    at afterConnect (net.js:896:19)
---------------------------------------------
    at Readable.on (_stream_readable.js:708:33)
    at http.js:1758:12
    at process._tickDomainCallback (node.js:486:13)
---------------------------------------------
    at ClientRequest.onSocket (http.js:1735:11)
    at Agent.addRequest (http.js:1274:9)
    at new ClientRequest (http.js:1421:16)
    at exports.request (http.js:1848:10)
    at /home/xxx/node_modules/proxy-middleware/index.js:50:17
 ...

binarykitchen avatar Mar 05 '15 03:03 binarykitchen

I closed my server manually by server.close(), but node process didn't exited. It happens only when proxy-middleware is active. Proxy requests are still hanging around.

The reason for that is aborded/unexpectedly closed proxy requests are not handled properly. There should be something like

req.on('close', function () {
    myReq.abort();
});

While this code appears to work, it generates socket hang up errors.

Frizi avatar May 11 '15 14:05 Frizi

@andrewrk ?

binarykitchen avatar May 11 '15 21:05 binarykitchen