Skip to content

fix: Reject all pending query promises when a query fails before resolving with a value for the first time - #16890

Merged
Rich-Harris merged 2 commits into
version-3from
elliott/reject-queries
Aug 22, 2026
Merged

fix: Reject all pending query promises when a query fails before resolving with a value for the first time#16890
Rich-Harris merged 2 commits into
version-3from
elliott/reject-queries

Conversation

@elliott-with-the-longest-name-on-github

@elliott-with-the-longest-name-on-github elliott-with-the-longest-name-on-github commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Closes #16848

Failure Sequence

  1. Query request A starts before the query has ever loaded successfully. #ready is false.
  2. A refresh starts request B while A is still pending.
  3. B fails.
  4. The query marks B’s error, but resolves A’s internal promise because B superseded it.
  5. A’s public promise waits for tick(), then returns #current.
  6. Because no request has succeeded, #current is undefined.
  7. The component receives undefined rather than a rejected promise, so <svelte:boundary> does not render its failure snippet. Accessing something like result.map(...) instead throws later.

The same problem occurs when fail() clears pending requests.

Fix

If we see that the internal promise has resolved but #ready has not yet been set, reject with #error (or a fallback, which shouldn't ever be reached).

@pkg-svelte-dev

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 61fb015:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/61fb0156addb8666a86a883cb226b2c8878d8385

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/kit/pr/16890

@changeset-bot

changeset-bot Bot commented Aug 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 61fb015

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

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit 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

@svelte-docs-bot

Copy link
Copy Markdown

@Rich-Harris
Rich-Harris merged commit 428e5ef into version-3 Aug 22, 2026
40 checks passed
@Rich-Harris
Rich-Harris deleted the elliott/reject-queries branch August 22, 2026 12:15
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.

Awaited query resolves with undefined instead of rejecting, boundary never catches it

2 participants