pull/18526/merge
Thribhuvan 1 week ago committed by GitHub
commit c0f4f66849
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: ensure a batch exists when a boundary resolves synchronously

@ -286,7 +286,7 @@ export class Boundary {
this.#pending_effect = null;
});
this.#resolve(/** @type {Batch} */ (current_batch));
this.#resolve(Batch.ensure());
}
});
}
@ -308,7 +308,10 @@ export class Boundary {
const pending = /** @type {(anchor: Node) => void} */ (this.#props.pending);
this.#pending_effect = branch(() => pending(this.#anchor));
} else {
this.#resolve(/** @type {Batch} */ (current_batch));
// `current_batch` can be null here — e.g. a `flushSync()` at the top
// level of a component script flushes and clears the batch while
// we are still rendering (#18522) — so ensure one exists
this.#resolve(Batch.ensure());
}
} catch (error) {
this.error(error);

@ -0,0 +1,6 @@
import { test } from '../../test';
// https://github.com/sveltejs/svelte/issues/18522
export default test({
html: `<h1>Hello!</h1>`
});

@ -0,0 +1,7 @@
<script>
import { flushSync } from 'svelte';
flushSync();
</script>
<h1>Hello!</h1>
Loading…
Cancel
Save