Repository navigation
fix(serverRouteComponent): hand a bare GET preload's call to the render - #682
Merged
Merged
Conversation
…er (#677) A bare GET(fn) source has no cache, so a link preload and the render it warmed each sent the request. Keep the preload's result for the next render with the same args (once, within query's preload window), share it between concurrent preloads, and drop it when it fails. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V4hL2itq3ojS2Wy1acXctX
🦋 Changeset detectedLatest commit: 5943f7f 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Ryan · project thread
Before: on a route with a bare
GET(fn)source inserverRouteComponent, a link's preload and the render that followed it each sent the same request. Even with #680, a click sent two identical GETs, and withno-storethe browser ran them one after the other.After: the render mounts the call the preload already started, so one visit sends one request.
The preload's result is handed to the next render with the same args, once, within the same 5 s window
query()gives a preload. A later visit calls fresh, as a bare GET always does. Concurrent preloads of the same args share one call. A failed preload isn't handed on, so the render retries.query()andliveQuery()sources, plain functions and the server render are unchanged. Because each result reaches exactly one render, a frame stream is never mounted twice, which answers the open question in the issue.How:
handOffPreloadsinsrc/serverRouteComponent.tswraps the source once, so it covers bothpreloadRoute'sserver.calland the render'scall. It tells them apart bygetIntent() === "preload", and keys byJSON.stringify(args).Closes #677.
Testing
test/server-routes.spec.tsxunder "a bare GET source". Two of them fail without the fix.pnpm test: 700 + 96 server specs and types all passpnpm build: clean🤖 Generated with Claude Code
https://claude.ai/code/session_01V4hL2itq3ojS2Wy1acXctX
Generated by Claude Code