fix: skip calling respond
for server-side fetch
on prerendered pages
#13377
+88
−2
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.
Server-side
fetch()
(e.g. whenisSubRequest: true
) currently has a few bugs when called on aprerendered
route.export const prerender = 'auto'
). Fixes Global slug overrides prerendered route when accessed from another route with event.fetch, but ok from client? #12739.hooks.server.js
run on them, but only whenisSubRequest: true
I've fixed both of these issues by adding a
prerendered_routes: Set<string>
to the manifest. Then, we instantly call a real HTTPfetch()
if the path matches, just like when calling server-sidefetch()
on assets (when the adapter doesn't support reading assets from the file-system).During dev/build, there are no
prerendered_routes
, so it's left empty in the manifest (although that does mean themanifest-full.js
also excludes it!)Potential issues
prerendered.paths
(which I'm using to setprerendered_routes
), it only has the routes without a trailing slash. Would this be an issue? If so, the code might get a lot more complicated!kit/packages/kit/src/types/private.d.ts
Lines 189 to 190 in 873a09e
prerendered_redirects
, so that we can follow the redirect chain without having to make a real HTTP request, but I think that should be fine if this is under the private_
field in themanifest.js
file.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
pnpm test
fails onmain
locally for me, so let's see if the CI passes on it!Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.Edits