You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(web): send without a microtask when prepareRequest is sync (#3959) - #3990
Fixes#3959. Supersedes #3988 by @brenelz: this is his commit, unchanged and still authored by him, plus one follow-up commit for the test's types. His fork's branch can't be pushed from here.
With any prepareRequest hook configured, even init => init, a server-function read that hydration adopted was fetched again from the browser. Hydration runs an adopted source's compute once inside subFetch, which swaps window.fetch for a never-settling mock only for that synchronous call. createRequest always awaited the hook, so even a synchronous hook pushed send(base, init) one microtask later, after the real fetch was restored.
createRequest now awaits the hook's result only when it is a thenable. A synchronous hook sends in the calling tick. An async hook is still awaited, and the prepareRequest docs now say that an async hook makes hydrated reads fetch again.
Follow-up commit
test-types failed on #3988: test/hydration/prepare-request-hydration-3959.spec.tsx imported sharedConfig from "solid-js". It now imports it from "solid-js/internal", like the other hydration specs.
Verification
pnpm run test-types in packages/web: clean.
test/server/server-functions-extensions.spec.tsx (13) and test/hydration/prepare-request-hydration-3959.spec.tsx (2) pass. With server-functions/src/client.ts reverted to next, the new case in each fails.
⚠️ Over the brotli cap within the minified allowance (passes)
app: CSR, observe tier (same app on the observe artifacts): over brotli cap by 5 B; minified 41,274 B vs 41,305 B recorded with the cap (−31 B) — 51 B of the 20 B minified allowance left; +0 B minified over this PR's base
Bundled with Rolldown (what Vite ships), brotli q11, decimal KB. A scenario fails only when it is over its brotli cap and its minified size is more than 20 B over the minified recorded with the cap; over the cap within that allowance is brotli layout noise and passes with a warning. Caps and their recorded minified in scripts/size/scenarios.js; the floor and page caps in floor-caps.json are frozen (lower only, or Size-Exception: in the PR body). npm run ratchet lowers caps per RC; it never raises one (scripts/size/README.md).
⚠️2 benchmarks spent significant time in system calls
System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.
Comparing fix/prepare-request-sync-3959 (1bd35bb) with next (b460640)
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
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.
Fixes #3959. Supersedes #3988 by @brenelz: this is his commit, unchanged and still authored by him, plus one follow-up commit for the test's types. His fork's branch can't be pushed from here.
Summary (from #3988)
With any
prepareRequesthook configured, eveninit => init, a server-function read that hydration adopted was fetched again from the browser. Hydration runs an adopted source's compute once insidesubFetch, which swapswindow.fetchfor a never-settling mock only for that synchronous call.createRequestalways awaited the hook, so even a synchronous hook pushedsend(base, init)one microtask later, after the realfetchwas restored.createRequestnow awaits the hook's result only when it is a thenable. A synchronous hook sends in the calling tick. An async hook is still awaited, and theprepareRequestdocs now say that an async hook makes hydrated reads fetch again.Follow-up commit
test-typesfailed on #3988:test/hydration/prepare-request-hydration-3959.spec.tsximportedsharedConfigfrom"solid-js". It now imports it from"solid-js/internal", like the other hydration specs.Verification
pnpm run test-typesinpackages/web: clean.test/server/server-functions-extensions.spec.tsx(13) andtest/hydration/prepare-request-hydration-3959.spec.tsx(2) pass. Withserver-functions/src/client.tsreverted tonext, the new case in each fails.Left open (from #3988)
A hydrated read whose arguments need the rich-argument codec still refetches, because of
await serializeArguments(args), with or without a hook.🤖 Generated with Claude Code
https://claude.ai/code/session_017PDt8Jv6uf5xRDsrux4UwF
Generated by Claude Code