When using got as a promise, the new beforeError hook is not effective since the the hook is not invoked in any non-network issue (e.g. 401)
Here is a simple example demonstrating the bug
got(`https://api.github.com`, {
headers: {
Authorization: 'Bearer invalid_token'
},
hooks: {
beforeError: [error => console.log('Houston, we have a problem')]
}
});
Expected Behaviour
It should print Houston, we have a problem.
Actual Behaviour
Nothing is printed, an error is thrown directly.
Reason
The error should have been parsed by the hook before rejecting, something like
https://github.com/sindresorhus/got/blob/92b1005cc4098a71f9ac8f984b61c07180ff77e8/source/request-as-event-emitter.ts#L45-L48
But there's none for promise
https://github.com/sindresorhus/got/blob/92b1005cc4098a71f9ac8f984b61c07180ff77e8/source/as-promise.ts#L80-L85 https://github.com/sindresorhus/got/blob/92b1005cc4098a71f9ac8f984b61c07180ff77e8/source/as-promise.ts#L93-L96
Hey guys, is there any time window for a new release containing the fix for this?
In meantime, is there any workaround for this?
We finally have an alpha version out: https://github.com/sindresorhus/got/releases/tag/v10.0.0-alpha.1
nice to see the new alpha version :tada: , but since it is an alpha version feel like I must ask:
do you plan to include the fix in a patch for v9.6?
Most helpful comment
We finally have an alpha version out: https://github.com/sindresorhus/got/releases/tag/v10.0.0-alpha.1