[FIX] lifecyle_hooks: correctly wrap errors in async code

Before this commit, wrapping an error occurring in async code
would result in an unhandledpromise exception, because we created
another promise, that would be rejected and that we didn't catch.
This commit is contained in:
Aaron Bohy
2022-07-15 16:04:19 +02:00
committed by Géry Debongnie
parent d1118455aa
commit 30bc605c84
3 changed files with 51 additions and 1 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ function wrapError(fn: (...args: any[]) => any, hookName: string) {
if (hookName === "onWillStart" || hookName === "onWillUpdateProps") {
const fiber = node.fiber;
Promise.race([
result,
result.catch(() => {}),
new Promise((resolve) => setTimeout(() => resolve(TIMEOUT), 3000)),
]).then((res) => {
if (res === TIMEOUT && node.fiber === fiber) {