Skip to content

Commit 769dd7d

Browse files
committed
move unset_context call
1 parent e55c882 commit 769dd7d

File tree

1 file changed

+2
-2
lines changed
  • packages/svelte/src/internal/client/reactivity

1 file changed

+2
-2
lines changed

packages/svelte/src/internal/client/reactivity/deriveds.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,11 @@ export function async_derived(fn, location) {
126126
try {
127127
// If this code is changed at some point, make sure to still access the then property
128128
// of fn() to read any signals it might access, so that we track them as dependencies.
129+
// We call `unset_context` to undo any `save` calls that happen inside `fn()`
129130
Promise.resolve(fn()).then(d.resolve, d.reject).then(unset_context);
130131
} catch (error) {
131132
d.reject(error);
133+
unset_context();
132134
}
133135

134136
if (DEV) current_async_effect = null;
@@ -185,8 +187,6 @@ export function async_derived(fn, location) {
185187
boundary.update_pending_count(-1);
186188
if (!pending) batch.decrement();
187189
}
188-
189-
unset_context();
190190
};
191191

192192
d.promise.then(handler, (e) => handler(null, e || 'unknown'));

0 commit comments

Comments
 (0)