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
throwHttpErrors: false suppresses ky.TimeoutError #246
Comments
Indeed, you are correct that const response = await ky('https://httpstat.us/200?sleep=1000', {
timeout : 1,
throwHttpErrors : false
});
console.log(response); // undefined I don't like this behavior, either, at least with the current option name. An
Based on my reading of the code, it looks like this behavior has always existed since the introduction of PR #14, where Some possible ways forward:
|
0.8.0 seems to be the earliest release that throws the timeout error with But it doesn't throw http errors, either. It could be that what I remember was using a release between 0.9.0 and 0.3.0 🤷♂ <script type="module">
import ky from 'https://cdn.jsdelivr.net/npm/ky@0.8.0/index.js';
// import ky from 'https://cdn.jsdelivr.net/npm/ky@latest/index.js';
(async () => {
try {
const r = await ky('https://httpstat.us/401?sleep=1000', {timeout: 1, throwHttpErrors: false});
} catch (e) {
console.log(e.name);
}
// nothing thrown for this
await ky('https://httpstat.us/401', {throwHttpErrors: true});
})();
</script> |
I would prefer 2B. |
A failing test for this would be much appreciated, as I am planning to work on it in the next few days. |
@StephenCarboni I have opened PR #334 to fix this bug. It would be great if you could try my branch and confirm that it works for you. |
Looks okay. I'm getting a TimeoutError with example in OP. |
I could have sworn that this did not use to be the case, but it's not useful to not throw on non-200 codes and lose TimeoutErrors, which have nothing to do with HTTP errors.
The response above is undefined. Which leaves me unable to tell why it's undefined.
How else are we expected to determine if a response timed out but we want to handle HTTP errors manually?
The text was updated successfully, but these errors were encountered: