async-fork
Dominic Gannaway 7 months ago
parent e02606a1e6
commit 75449ed6e4

@ -171,7 +171,7 @@ export function boundary(node, props, children) {
for (var [signal, entry] of forks) { for (var [signal, entry] of forks) {
if (signal.v !== entry.v) { if (signal.v !== entry.v) {
if ((signal.f & (DERIVED | ASYNC_DERIVED)) === 0) { if ((signal.f & (DERIVED | ASYNC_DERIVED)) === 0) {
mark_reactions(signal, DIRTY, true); mark_reactions(signal, DIRTY, undefined, true);
signal.wv = increment_write_version(); signal.wv = increment_write_version();
} }
} }

@ -261,9 +261,10 @@ export function update_pre(source, d = 1) {
/** /**
* @param {Value} signal * @param {Value} signal
* @param {number} status should be DIRTY or MAYBE_DIRTY * @param {number} status should be DIRTY or MAYBE_DIRTY
* @param {Value} [parent]
* @returns {void} * @returns {void}
*/ */
export function mark_reactions(signal, status, only_boundary = false) { export function mark_reactions(signal, status, parent, only_boundary = false) {
var reactions = signal.reactions; var reactions = signal.reactions;
if (reactions === null) return; if (reactions === null) return;
@ -281,9 +282,10 @@ export function mark_reactions(signal, status, only_boundary = false) {
if (!runes && reaction === active_effect) continue; if (!runes && reaction === active_effect) continue;
if (only_boundary) { if (only_boundary) {
var effect = /** @type {Effect} */ (reaction);
if ((flags & DERIVED) === 0) { if ((flags & DERIVED) === 0) {
var boundary = get_boundary(/** @type {Effect} */ (reaction)); var boundary = get_boundary(effect);
if (!boundary || (reaction.f & ASYNC_DERIVED) !== 0) { if (!boundary || ((reaction.f & ASYNC_DERIVED) !== 0 && !(signal.v instanceof Promise))) {
continue; continue;
} }
} }
@ -292,7 +294,7 @@ export function mark_reactions(signal, status, only_boundary = false) {
if (boundary) { if (boundary) {
// @ts-ignore // @ts-ignore
var forks = boundary.fn.forks; var forks = boundary.fn.forks;
if (reaction.deps?.every((d) => forks.has(d))) { if (reaction.deps?.every((d) => forks.has(d)) || forks.has(parent)) {
continue; continue;
} }
} }
@ -309,7 +311,7 @@ export function mark_reactions(signal, status, only_boundary = false) {
// If the signal a) was previously clean or b) is an unowned derived, then mark it // If the signal a) was previously clean or b) is an unowned derived, then mark it
if ((flags & (CLEAN | UNOWNED)) !== 0) { if ((flags & (CLEAN | UNOWNED)) !== 0) {
if ((flags & DERIVED) !== 0) { if ((flags & DERIVED) !== 0) {
mark_reactions(/** @type {Derived} */ (reaction), MAYBE_DIRTY, only_boundary); mark_reactions(/** @type {Derived} */ (reaction), MAYBE_DIRTY, signal, only_boundary);
} else { } else {
schedule_effect(/** @type {Effect} */ (reaction)); schedule_effect(/** @type {Effect} */ (reaction));
} }

@ -30,6 +30,7 @@ export default test({
await tick(); await tick();
assert.htmlEqual(target.innerHTML, '<p>42</p>'); assert.htmlEqual(target.innerHTML, '<p>42</p>');
// This runs fine locally, but fails in CI by overfiring some effects?
component.num = 2; component.num = 2;
await Promise.resolve(); await Promise.resolve();
await Promise.resolve(); await Promise.resolve();

@ -28,6 +28,7 @@ export default test({
flushSync(); flushSync();
assert.htmlEqual(target.innerHTML, '<p>42</p>'); assert.htmlEqual(target.innerHTML, '<p>42</p>');
// This runs fine locally, but fails in CI by overfiring some effects?
component.num = 2; component.num = 2;
await Promise.resolve(); await Promise.resolve();
await Promise.resolve(); await Promise.resolve();

Loading…
Cancel
Save