The request is taking longer to respond but the timings in the error object look correct:
When executing the sample code, execution is taking above 6 seconds even if the timeout is 1.
The request should last ~1000ms, it can be a few milliseconds more due to processing time, let's say max 1010ms.
import got from 'got'
;(async () => {
const start = new Date()
const res = await got('https://httpbin.org/delay/10', { timeout: { request: 1000 } }).catch(err => err)
const end = new Date()
console.log(res)
console.log({ diff: (end - start) / 1000 })
})().catch(console.error)
// Output:
// ... error
// { diff: 6.185 }
I also have this in my tsconfig.json:
"paths": {
"got": ["./node_modules/got/dist/source"]
}
I've also tested this scenario with a brand new project and latest Got and I'm able to reproduce.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too