From a9e82dd388815bdd3c86bec88afd997ec0dfe342 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 29 May 2026 07:51:17 -0400 Subject: [PATCH] chore: remove `on_fork_commit` (#18318) Simon thinks it was because he thought that committing the fork != committing the batch, and that this could result in an error boundary showing up too late. But that's not the case --- .../internal/client/dom/blocks/boundary.js | 2 +- .../src/internal/client/reactivity/batch.js | 21 ------------------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/packages/svelte/src/internal/client/dom/blocks/boundary.js b/packages/svelte/src/internal/client/dom/blocks/boundary.js index beaa7d6869..0c0903ff52 100644 --- a/packages/svelte/src/internal/client/dom/blocks/boundary.js +++ b/packages/svelte/src/internal/client/dom/blocks/boundary.js @@ -396,7 +396,7 @@ export class Boundary { if (this.#pending_effect) current_batch.skip_effect(this.#pending_effect); if (this.#failed_effect) current_batch.skip_effect(this.#failed_effect); - current_batch.on_fork_commit(() => { + current_batch.oncommit(() => { this.#handle_error(error); }); } else { diff --git a/packages/svelte/src/internal/client/reactivity/batch.js b/packages/svelte/src/internal/client/reactivity/batch.js index 8dbcacf429..3b82059788 100644 --- a/packages/svelte/src/internal/client/reactivity/batch.js +++ b/packages/svelte/src/internal/client/reactivity/batch.js @@ -140,12 +140,6 @@ export class Batch { */ #discard_callbacks = new Set(); - /** - * Callbacks that should run only when a fork is committed. - * @type {Set<(batch: Batch) => void>} - */ - #fork_commit_callbacks = new Set(); - /** * The number of async effects that are currently in flight */ @@ -634,7 +628,6 @@ export class Batch { discard() { for (const fn of this.#discard_callbacks) fn(this); this.#discard_callbacks.clear(); - this.#fork_commit_callbacks.clear(); this.#unlink(); this.#deferred?.resolve(); @@ -840,16 +833,6 @@ export class Batch { this.#discard_callbacks.add(fn); } - /** @param {(batch: Batch) => void} fn */ - on_fork_commit(fn) { - this.#fork_commit_callbacks.add(fn); - } - - run_fork_commit_callbacks() { - for (const fn of this.#fork_commit_callbacks) fn(this); - this.#fork_commit_callbacks.clear(); - } - settled() { return (this.#deferred ??= deferred()).promise; } @@ -1410,10 +1393,6 @@ export function fork(fn) { source.wv = increment_write_version(); } - batch.activate(); - batch.run_fork_commit_callbacks(); - batch.deactivate(); - // trigger any `$state.eager(...)` expressions with the new state. // eager effects don't get scheduled like other effects, so we // can't just encounter them during traversal, we need to