-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Specify incoming request socket timeout #1113
Comments
FWIW, I was able to work around this via const LONG_PYTHON_TIMEOUT = 15 * 60 * 1000;
const pythonProxy = new httpProxy.createProxyServer({
target: {
host: 'localhost',
port: pythonPort
},
proxyTimeout: LONG_PYTHON_TIMEOUT,
})
app.all('/api/*', (req, res) =>
pythonProxy.web(req.setTimeout(LONG_PYTHON_TIMEOUT), res)) I just set the request timeout in the handler lambda before passing into the proxy handler itself. That said: right or wrong, I 100% expected it to set the request timeout for me, mostly because I didn't even know that was a thing until I ran into the timeout in a long test. So I have no idea what arguments might exist against setting the |
This ensures the incoming request does not timeout before the target's timeout configured with `options.proxyTimeout` Fixes http-party#1113
Was this fixed or not? |
Afraid not, sadly there hasn't been any feedback from the maintainers so far. |
Hi!
I've found an issue allowing long running proxied connections to stay open. In this case, it's something we've seen related to the webpack dev server which has this http-proxy package as its dependency via http-proxy-middleware.
In practise what we've seen is that long running proxied requests are being closed after 2 minutes, even though we specify a longer timeout with the proxyTimeout option. That in turn may make some browser automatically retry the request which failed, which is absolutely not wanted in some scenarios -- the latter isn't really this package's fault, so feel free to ignore that part.
After digging for a while I found the root cause to be in this package's request handler (lib/http-proxy/index.js). By not setting a timeout on the incoming HTTP socket with request.setTimeout(), Node.js core sets 2 minutes by default.
Ideally we'd like to be able to set proxyTimeout to whatever number we want and be sure that's respected. That possibly means using the same value in
request.setTimeout()
.Does this sound okey to you? Any other thoughts?
Refs webpack/webpack-dev-server#369 (comment)
/cc @Martin-Wegner
The text was updated successfully, but these errors were encountered: