fix: reuse hydrated remote query data#15857
Conversation
🦋 Changeset detectedLatest commit: 1ebb6dc The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
elliott-with-the-longest-name-on-github
left a comment
There was a problem hiding this comment.
Yeah, we can't merge this -- it's not the correct solution to the problem. Here's why:
- Multiple different query references could need to resolve data from the
hydratablecache at different times, so deleting after read would mean "first instance wins" - The
hydratablestore 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).
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:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits