Timeout option not working with proxy (using tunnel as proxy)
got('https://example.com', {
timeout: 50,
agent: {
https: tunnel.httpsOverHttp({
proxy: {
host: '175.44.108.137',
port: 9999
}
})
}
})
set agent https to tunnel.httpsOverHttp, got timeout is invalid!!!
timeout is milliseconds, not seconds.
I know timeout is milliseconds!
My question is Timeout option not working with proxy (using tunnel as proxy)
Timeout option is not work, when i add 'proxy agent' option
if i remove 'proxy agent', timeout is work.
but I need them both, and how could i figure it out?
Is there any solution to this bug or an alternative way to timeout a request with a proxy? If not, is a fix planned soon?
Running into this issue as well, if anyone knows of a workaround it would be greatly appreciated
A workaround is to utilise the cancel method with a setTimeout. It won't give you a TimeoutError, but it does the job and throw you an error.
const request = got(options);
const timeout = setTimeout(() => request.cancel(), this.timeout);
const response = await request;
clearTimeout(timeout);
The same problem.

A workaround is to utilise the
cancelmethod with asetTimeout. It won't give you a TimeoutError, but it does the job and throw you an error.const request = got(options); const timeout = setTimeout(() => request.cancel(), this.timeout); const response = await request; clearTimeout(timeout);
got.cancel is not a function
It's request.cancel, not got.cancel. ;)
Same problem here, what is exactly the reason for that error? the 'request' timeout should start even before trying to connect to the proxy right? why is not working?
@jolivaSan https://github.com/sindresorhus/got/issues/1393#issuecomment-670164753
Most helpful comment
A workaround is to utilise the
cancelmethod with asetTimeout. It won't give you a TimeoutError, but it does the job and throw you an error.