-
-
Notifications
You must be signed in to change notification settings - Fork 357
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
beforeError hook isn't called on 500 responses #575
Comments
Does 404 work? What environment are you running in? Native Fetch or node-fetch? We have a test to confirm it's working: Lines 610 to 640 in 2d56baf
|
It's in native fetch and 404 is working. I can't imagine it would make a difference but I'm noticing it on a PUT req. I've also checked it on Firefox and Chrome. Its options req is 200, I can't remember if it's the same outcome when an options req is 500 |
I am unable to reproduce this. Would you mind trying to make an example on CodeSandbox, StackBlitz, or RunKit? Here is what I tried: import ky from 'https://esm.sh/ky@1';
let hookCalls = 0;
const api = ky.create({
retry: 0,
hooks: {
beforeError: [
(error) => {
hookCalls++;
console.log('hook call:', hookCalls);
}
]
}
});
await api.get('https://httpbin.org/status/500');
await api.post('https://httpbin.org/status/500');
await api.put('https://httpbin.org/status/500');
await api.patch('https://httpbin.org/status/500');
await api.head('https://httpbin.org/status/500');
console.log(hookCalls === 5); // => true My best guess at this point is either:
It may also be worth trying to eliminate that |
Looks like it was a server configuration issue on our end, I believe it's resolved now. Thanks for the check in |
Hey I've encountered an issue when receiving 500 server codes from an api. For whatever reason it doesn't seem like the
beforeError
hook gets called. The following instance isn't producing any logs in the console when I hit a 500.I've confirmed that the same code is fine for 404s and other 400 codes. Here are the raw response headers for the 500
and the 404
The text was updated successfully, but these errors were encountered: