Skip to content

Commit

Permalink
fix(runtime): catch errors in async lifecycle methods (#5826)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner-reits authored Jun 13, 2024
1 parent 98bbd7c commit 87e5b33
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/runtime/update-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,12 @@ const dispatchHooks = (hostRef: d.HostRef, isInitialLoad: boolean): Promise<void
* @returns either a `Promise` or the return value of the provided function
*/
const enqueue = (maybePromise: Promise<void> | undefined, fn: () => Promise<void>): Promise<void> | undefined =>
isPromisey(maybePromise) ? maybePromise.then(fn) : fn();
isPromisey(maybePromise)
? maybePromise.then(fn).catch((err) => {
console.error(err);
fn();
})
: fn();

/**
* Check that a value is a `Promise`. To check, we first see if the value is an
Expand Down

0 comments on commit 87e5b33

Please sign in to comment.