Skip to content

fix: reuse hydrated remote query data#15857

Open
TehBrian wants to merge 1 commit into
sveltejs:mainfrom
TehBrian:codex/fix-remote-query-hydration-waterfall
Open

fix: reuse hydrated remote query data#15857
TehBrian wants to merge 1 commit into
sveltejs:mainfrom
TehBrian:codex/fix-remote-query-hydration-waterfall

Conversation

@TehBrian
Copy link
Copy Markdown

closes #15791

See #15791 for all the details, but essentially, the problem is that CSR will re-request hydrated derived remote functions, ignoring the hydratable cache.

Very possibly slop PR, my apologies if so! I'm totally inexperienced with Kit's internals, but I've been blocked on #15791 for a little while, and I figured I could give fixing it with Codex a shot. Here's my full conversation: https://pastes.dev/ZTYmShj1Iu

I read its output/diff, and it all seems to make sense, but I'm worried that the model looked in the completely wrong spot and isn't actually fixing the root issue. If that's the case, please feel free to close/disregard this PR. Just trying to help :-)


Please don't delete this checklist! 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
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

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

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 16, 2026

🦋 Changeset detected

Latest commit: 1ebb6dc

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, we can't merge this -- it's not the correct solution to the problem. Here's why:

  1. Multiple different query references could need to resolve data from the hydratable cache at different times, so deleting after read would mean "first instance wins"
  2. The hydratable store is not public API, even for SvelteKit -- different versions of Svelte could change its shape or even remove it altogether in favor of some other abstraction, which would break this solution

The problem (AFAICT) is that something is kicking the subsequent waterfalled invocations out of the hydration pipeline. Inside svelte, there's a hydrating boolean that's set to true when hydration is occuring and false whenever it's not. hydratable will only read from the hydratable map whenever hydrating is true. It should be true in this broken case, but it seems like we're somehow breaking out of hydration (probably with a microtask somewhere there's not supposed to be one, or because of a bug in our handling inside of Svelte).

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.

Awaiting remote function causes the next to be unnecessarily rerun on the client

2 participants