Timeout doesn't behave like documented
try {
await Promise.race([
new Promise((resolve, reject) => setTimeout(() => reject(new Error("my timeout")), 2000)),
ky("https://pie.dev/status/429", {
retry: {
limit: 15,
},
timeout: 1000,
}),
]);
} catch (err: unknown) {
console.log(err); // Error: my timeout
}
The documentation says:
Timeout in milliseconds for getting a response, including any retries. Can not be greater than 2147483647. If set to false, there will be no timeout.
Reading this, I expected the code above to throw TimeoutError after 1000 ms, but rather it throws "my timeout" after 2000 ms.
What was the real intention here?
Hi! I’d like to work on this issue and submit a PR. I can help clarify the behavior of timeout in Ky with Promise.race and provide a minimal example demonstrating the expected behavior. Could you please assign this to me?
This should be fixed, but it's a breaking change to fix this at this point, so should be done for v2.
@KirtiGautam620 Thanks for offering, but I prefer to do the change myself. It's a little bit involved and an outside contribution would take more effort than fixing this ourselves.