Skip to content

Commit

Permalink
fix: clear error handlers before each computed run
Browse files Browse the repository at this point in the history
  • Loading branch information
mihar-22 committed Nov 25, 2022
1 parent 58df985 commit 8a716cd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/observables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ export function computed<T>(fn: () => T, options?: ComputedOptions<T>): Observab
$computed[DISPOSAL].clear();
}

$computed[CONTEXT]?.[ERROR]?.clear();

const nextValue = compute($computed, fn);
if (isDirty(currentValue, nextValue)) {
currentValue = nextValue;
Expand Down
2 changes: 1 addition & 1 deletion tests/onError.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ it('should not duplicate error handler', async () => {
root(() => {
effect(() => {
$a();
onError(handler);
onError(() => handler());
if (shouldThrow) throw error;
});
});
Expand Down

0 comments on commit 8a716cd

Please sign in to comment.