[timeout decorator] Should catch the original exception if the method throw an error before timeout
Closed this issue · 1 comments
gongpeione commented
Hi, I am sorry for being late, I think these decorators you provide are super useful, but I have a little problem when I use the timeout decorator, if the method throw an error before timeout, I cannot catch the original error but timeout error.
Example code:
const ms = 50;
class T {
@timeout(ms)
async foo() {
await Promise.reject(1);
await sleep(100);
}
}
const t = new T();
try {
await t.foo();
} catch (e) {
console.log(e);
}
Current output : [Error: timeout occurred after 50]
Expect output : 1
Linked pull request: #142
vlio20 commented
issue resolved in 2.0.4. Thanks @gongpeione