Repository navigation
fix(web): preload the root error page so hydration skips a round trip - #347
Merged
Merged
Conversation
SvelteKit's client awaits the root error page (nodes/1) in start() before it hydrates, but the server only modulepreloads the route's own nodes (sveltejs/kit#17415). So every page fetched nodes/1 only after start.js had run, a round trip behind the largest chunk. Lighthouse's simulated LCP counts that request whenever it finishes before the first paint on localhost, which a busy machine makes likely. That took /projects/halflight from 2.10 s to 2.25 s, 48 ms under the 2.3 s budget, and one more simulated round trip put it over (2,404 and 2,408 ms). With nodes/1 preloaded alongside the other modules it's off the critical path: under 16 busy processes, halflight's 12 runs measured 2,100 to 2,118 ms (before: 2,103 to 2,256 ms, 8 of 12 at about 2,252), and / and /tools/locallibrary dropped about 150 ms too. The patch adds the root error page's imports to the modulepreloads. Drop it once a SvelteKit release has the fix (sveltejs/kit#17416). The build test now counts the root error page in what every page loads.
bnb
approved these changes
Oct 31, 2026
Coverage Report for apps/web
File CoverageNo changed files found.SizeCompared with main. KiB are 1,024 bytes.
|
Coverage Report for apps/localtoolbox
File CoverageNo changed files found.SizeCompared with main. KiB are 1,024 bytes.
|
Contributor
Author
|
Closing and reopening so CI runs on the new single-workflow CI against current main. Branch unchanged. |
botandbang
enabled auto-merge
October 31, 2026 23:34
botandbang
disabled auto-merge
October 31, 2026 23:46
2 tasks done
Contributor
Author
|
Closing and reopening so CI runs against current main (with #353's CodeQL fix). Branch unchanged. |
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.
What and why
SvelteKit's client awaits the root error page (
nodes/1) instart()before it hydrates, but the server only modulepreloads the route's own nodes (sveltejs/kit#17415). Every page fetchednodes/1only afterstart.jshad run, a round trip behind the largest chunk, before it could hydrate.That request is also why Lighthouse's LCP check on
/projects/halflightfailed on a busy machine (2,404 and 2,408 ms against 2,300). On localhost the first paint lands after the modules run, so the simulated LCP counts every request finished by then. Whennodes/1finished first, which a loaded host makes the usual case, the LCP went from 2,101 to 2,252 ms, and one more simulated round trip put it over the budget.Added:
patches/@sveltejs__kit@3.1.0.patch, which adds the root error page's imports to the modulepreloads (the root-error part of sveltejs/kit#17416), registered inpnpm-workspace.yamlwith a note to drop it once a release has the fix.Changed:
tests/build.test.tscounts the root error page in the JavaScript every page loads (now about 179 KiB of the 180 KiB budget), since every page downloads it.Removed: nothing. The Lighthouse config and its 2,300 ms LCP limit are unchanged.
How it was tested
Full
lhci collecton a fresh network, 4 times x 3 runs, with 16 busy processes on the machine:/projects/halflightLCP over the 12 runs went from 2,103 to 2,256 ms (8 of 12 at about 2,252) to 2,100 to 2,118 ms, and/and/tools/locallibrarydropped about 150 ms too. Direct Lighthouse runs with 48 busy processes went from a median of 2,254 ms (max 2,261) to 2,102 ms (max 2,160). The simulated FCP rose about 75 ms because lantern counts the extra modulepreload as blocking; FCP isn't asserted and the performance score stayed at 0.98.Ran
pnpm verify,pnpm test:lighthouseandpnpm test:e2e --project chromiumin apps/web, plustools/policy.shandast-grep scan.Checklist
docs/and--helpstill say what the code does