holy shit everything passes

pull/17805/head
Rich Harris 6 months ago
parent 58f6c1f116
commit 7282aa1be6

@ -303,6 +303,9 @@ export function wait(blockers) {
return Promise.all(blockers.map((b) => b.promise));
}
/**
* @returns {(skip: boolean) => void}
*/
export function increment_pending() {
var boundary = /** @type {Boundary} */ (/** @type {Effect} */ (active_effect).b);
var batch = /** @type {Batch} */ (current_batch);
@ -311,8 +314,8 @@ export function increment_pending() {
boundary.update_pending_count(1, batch);
batch.increment(blocking);
return () => {
return (skip) => {
boundary.update_pending_count(-1, batch);
batch.decrement(blocking);
batch.decrement(blocking, skip);
};
}

@ -441,7 +441,7 @@ export class Batch {
// Re-run async/block effects that depend on distinct values changed in both batches
const others = [...batch.current.keys()].filter((s) => !this.current.has(s));
if (others.length > 0) {
current_batch = batch;
batch.activate();
/** @type {Set<Value>} */
const marked = new Set();
@ -459,9 +459,9 @@ export class Batch {
}
// TODO do we need to do anything with the dummy effect arrays?
batch.deactivate();
}
batch.deactivate();
}
}
@ -483,14 +483,14 @@ export class Batch {
}
/**
*
* @param {boolean} blocking
* @param {boolean} skip - whether to skip updates (because this is triggered by a stale reaction)
*/
decrement(blocking) {
decrement(blocking, skip) {
this.#pending -= 1;
if (blocking) this.#blocking_pending -= 1;
if (this.#decrement_queued) return;
if (this.#decrement_queued || skip) return;
this.#decrement_queued = true;
queue_micro_task(() => {

@ -161,6 +161,13 @@ export function async_derived(fn, label, location) {
const handler = (value, error = undefined) => {
if (DEV) current_async_effect = null;
if (decrement_pending) {
// don't trigger an update if we're only here because
// the promise was superseded before it could resolve
var skip = error === STALE_REACTION;
decrement_pending(skip);
}
if (error === STALE_REACTION || (effect.f & DESTROYED) !== 0) {
return;
}
@ -198,10 +205,6 @@ export function async_derived(fn, label, location) {
}
}
if (decrement_pending) {
decrement_pending();
}
batch.deactivate();
};

@ -2,12 +2,6 @@ import { flushSync, tick } from 'svelte';
import { test } from '../../test';
export default test({
// TODO this test fails, because effects get scheduled on a batch that
// has already committed. there are some subtle timing issues
// that are exposed by the more rigorous implementation in this
// PR, and I'm still figuring out how to fix them
skip: true,
async test({ assert, target }) {
const [a, b, shift, pop] = target.querySelectorAll('button');

Loading…
Cancel
Save