Skip to content

Conversation

elliott-with-the-longest-name-on-github
Copy link
Contributor

@elliott-with-the-longest-name-on-github elliott-with-the-longest-name-on-github commented Sep 8, 2025

Prior to this PR, all pending count updates were forwarded to the nearest parent boundary with a pending snippet. This made $effect.pending incorrect if you had nested boundaries where an inner boundary didn't have a pending snippet.

This corrects the behavior and clarifies the meaning of a few concepts in the boundary code:

  • pending now explicitly means "this boundary is inside of a boundary (including this one) that is currently trying to render a pending snippet"
  • #pending_count now directly corresponds to $effect.pending for this boundary
  • #cascading_pending_count is the same but treats boundaries with no pending snippet as porous, which means pending snippet management can be managed separately from $effect.pending management
  • calling reset correctly manages the #cascading_pending_count and also explicitly only renders the pending snippet of the boundary being reset, not any of its parents
  • get_pending_snippet is dead. Code can now call get_snippet and use pending or update_pending_count and it will just do the right thing

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

@changeset-bot
Copy link

changeset-bot bot commented Sep 8, 2025

🦋 Changeset detected

Latest commit: 2fc7880

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

@github-actions
Copy link
Contributor

github-actions bot commented Sep 8, 2025

Playground

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

this.pending = true;
// we intentionally do not try to find the nearest pending boundary. If this boundary has one, we'll render it on reset
// but it would be really weird to show the parent's boundary on a child reset.
this.pending = this.has_pending_snippet();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think this is quite right, since this uses the getter which will set the parent to true if the current one doesn't have a pending snippet. Did you mean to do this?

Suggested change
this.pending = this.has_pending_snippet();
this.#pending = this.has_pending_snippet();


/**
* Whether this boundary is inside a boundary (including this one) that's showing a pending snippet.
* Derived from {@link props.pending} and {@link cascading_pending_count}.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That "derived from ..." part is confusing because that's not what's happening.

if (this.has_pending_snippet()) {
this.#pending = value;
} else if (this.parent) {
this.parent.pending = value;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The set pending logic feels extremely suspicious to me. In all cases where we're setting it to true, it's because the boundary in question has a pending snippet. Why would we ever want to set a parent boundary's pending state to false? If we comment out this line, no test fails. Just all feels wrong


/**
* Whether this boundary is inside a boundary (including this one) that's showing a pending snippet.
* Derived from {@link props.pending} and {@link cascading_pending_count}.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the @link syntax meant to do?

this.#pending_count += d;
/** @param {number} d */
#update_cascading_pending_count(d) {
this.#cascading_pending_count = Math.max(this.#cascading_pending_count + d, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh? this can't possibly be right

Suggested change
this.#cascading_pending_count = Math.max(this.#cascading_pending_count + d, 0);
this.#cascading_pending_count += d;

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.

3 participants