Skip to content

Conversation

paoloricciuti
Copy link
Member

Closes #16886

There were two problems here: the first is that when pending is an attribute we weren't checking if the fragment contained async...this means if you did use await in a boundary with a pending attribute it was not creating the $$render.async wrapper.

However, that showcased another problem in that generated code:

import 'svelte/internal/flags/async';
import * as $ from 'svelte/internal/server';

function pending($$renderer) {}

export default function App($$renderer) {
	if (pending) {
		$$renderer.push(`<!--[!-->${pending($$renderer)}<!--]-->`);
	} else {
		$$renderer.push(`<!--[-->`);

		{
			const x = (await $.save(Promise.resolve()))();
		}

		$$renderer.push(`<!--]-->`);
	}
}

if pending is truthy instead of just invoking it (since it will push it's content to the $$renderer) we were also pushing to the template the return value (which is undefined since it's not returning anything.

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.
  • If this PR changes code within packages/svelte/src, add a changeset (npx changeset).

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

Copy link

changeset-bot bot commented Oct 9, 2025

🦋 Changeset detected

Latest commit: 6651f5e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Oct 9, 2025

Playground

pnpm add https://pkg.pr.new/svelte@16919

@dummdidumm dummdidumm merged commit 7f8e60f into main Oct 9, 2025
18 checks passed
@dummdidumm dummdidumm deleted the boundary-pending-prop-async branch October 9, 2025 11:32
@github-actions github-actions bot mentioned this pull request Oct 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hydration_mismatch when pending snippet is passed as prop to <svelte:boundary>

2 participants