连接超时设置
作者: wrfighting创建于 2020年8月27日更新于 2024年10月18日
当我请求一个不存在的 IP 地址时,它会抛出 connect xxx timeout 错误。因此,我想设置 connect timeout。我发现我们可以使用 { response: xxx, deadline: xxx },但它对于 connect xxx timeout 并不适用。例如,{ response: 1000, deadline: 60000 }`app.get('/httpgetok', function (req, res, next) { setTimeout(() => { res.send('ok'); }, 30000) })` 会抛出 timeout 1000 错误,但我只想使用 response 1000 来设置 connect timeout,而不是 response timeout。
内容来源: forwardemail/superagent