-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: revert using server read for load function fetch #12876
Conversation
🦋 Changeset detectedLatest commit: 9a2fe16 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 |
not sure why lint is failing on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested this 8cba744 with aloisklink/sveltekit-2.7.0-issue-reproduction@2acc884 and it seems to work with Vercel serverless functions! See https://sveltekit-2-7-0-issue-reproduction-dp5l83ne5.vercel.app/
Be aware that this will probably cause a performance regression for Cloudflare/Node to pre-#12113.
I've also tested an alternative fix: aloisklink@f4aace9, which is just adding:
index 7e2177d66..417b59c93 100644
--- a/packages/kit/src/runtime/server/fetch.js
+++ b/packages/kit/src/runtime/server/fetch.js
@@ -97,7 +97,7 @@ export function create_fetch({ event, options, manifest, state, get_cookie_heade
return new Response(state.read(file), {
headers: type ? { 'content-type': type } : {}
});
- } else if (read_implementation) {
+ } else if (read_implementation && file in manifest._.server_assets) {
const length = manifest._.server_assets[file];
const type = manifest.mimeTypes[file.slice(file.lastIndexOf('.'))];
According to aloisklink/sveltekit-2.7.0-issue-reproduction@c3ee13c and the Vercel preview at https://sveltekit-2-7-0-issue-reproduction-itnyzmr86.vercel.app/, it also seems to work, but I don't think it would cause the same performance regression on Cloudflare. But I unfortunately don't have a Cloudflare setup to test this!
|
I think that's right - we can actually just check if |
closes #12868
This PR reverts a part of the change from #12113. The issue is caused by the
read
implementation trying to read the static asset from the server during afetch
, but it doesn't work since the static asset isn't packaged with the serverless function. I think having the distinction betweenfetch
andread
is good here.kit/packages/kit/src/runtime/server/fetch.js
Lines 100 to 110 in dcbe422
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
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