From fb7f4bc18b8c2c01117d28f3b72dfe5144988211 Mon Sep 17 00:00:00 2001 From: Ryan Carniato Date: Wed, 22 Nov 2023 10:39:48 -0800 Subject: [PATCH] fix #1950 leaking error tracking --- .changeset/olive-frogs-join.md | 5 +++++ packages/solid/src/reactive/signal.ts | 13 +++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 .changeset/olive-frogs-join.md diff --git a/.changeset/olive-frogs-join.md b/.changeset/olive-frogs-join.md new file mode 100644 index 000000000..8f5f2da32 --- /dev/null +++ b/.changeset/olive-frogs-join.md @@ -0,0 +1,5 @@ +--- +"solid-js": patch +--- + +fix #1950 leaking error tracking diff --git a/packages/solid/src/reactive/signal.ts b/packages/solid/src/reactive/signal.ts index 67c70f265..d17d45198 100644 --- a/packages/solid/src/reactive/signal.ts +++ b/packages/solid/src/reactive/signal.ts @@ -1324,10 +1324,7 @@ export function writeSignal(node: SignalState | Memo, value: any, isCo function updateComputation(node: Computation) { if (!node.fn) return; cleanNode(node); - const owner = Owner, - listener = Listener, - time = ExecCount; - Listener = Owner = node; + const time = ExecCount; runComputation( node, Transition && Transition.running && Transition.sources.has(node as Memo) @@ -1346,12 +1343,13 @@ function updateComputation(node: Computation) { }, false); }); } - Listener = listener; - Owner = owner; } function runComputation(node: Computation, value: any, time: number) { let nextValue; + const owner = Owner, + listener = Listener; + Listener = Owner = node; try { nextValue = node.fn(value); } catch (err) { @@ -1369,6 +1367,9 @@ function runComputation(node: Computation, value: any, time: number) { // won't be picked up until next update node.updatedAt = time + 1; return handleError(err); + } finally { + Listener = listener; + Owner = owner; } if (!node.updatedAt || node.updatedAt <= time) { if (node.updatedAt != null && "observers" in node) {