-
Notifications
You must be signed in to change notification settings - Fork 398
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
[Bug] Async hook doesn't catch error when reject a falsy value #176
Comments
Hm, why you pass |
This is just an example, my real case is: |
Can you try to use |
Of course, I can somehow ignore this case, but I think this can be made more robust. I don't use hooks directly, and I expose them to others, so I have to fix. Below shows how I fixed it. and I hope the official can fix it function _fixTapablePromiseHook(hook: Hook<any, any>) {
hook.intercept({
register: (tapInfo) => {
const originalFn = tapInfo.fn;
if (tapInfo.type === 'promise') {
tapInfo.fn = async function (...args: any[]) {
try {
return await originalFn.apply(tapInfo, args);
} catch (err) {
if (!err) err = new Error();
throw err;
}
};
}
return tapInfo;
},
});
} |
hm, looks good, feel free to send a PR |
Hi, I would like to take this issue !! |
Hi, I seem to have found a bug:
Environment
Case
Expected output:
Error: 0
But the actual output:
Success
The text was updated successfully, but these errors were encountered: