Skip to content

Commit

Permalink
fix(watch): catch error from returned promise
Browse files Browse the repository at this point in the history
  • Loading branch information
Mini-ghost committed Sep 19, 2024
1 parent c118104 commit 65e6a10
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions packages/reactivity/src/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,13 @@ export function watch(
if (isFunction(maybeCleanup)) {
boundCleanup(maybeCleanup)
} else if (isPromise(maybeCleanup)) {
maybeCleanup.then(cleanup => {
if (isFunction(cleanup)) {
boundCleanup(cleanup)
}
})
maybeCleanup
.then(cleanup => {
if (isFunction(cleanup)) {
boundCleanup(cleanup)
}
})
.catch(NOOP)
}
} finally {
activeWatcher = currentEffect
Expand Down Expand Up @@ -282,11 +284,13 @@ export function watch(
if (isFunction(maybeCleanup)) {
boundCleanup(maybeCleanup)
} else if (isPromise(maybeCleanup)) {
maybeCleanup.then(cleanup => {
if (isFunction(cleanup)) {
boundCleanup(cleanup)
}
})
maybeCleanup
.then(cleanup => {
if (isFunction(cleanup)) {
boundCleanup(cleanup)
}
})
.catch(NOOP)
}
oldValue = newValue
} finally {
Expand Down

0 comments on commit 65e6a10

Please sign in to comment.