Skip to content
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: use window.fetch for server load fetch requests #13315

Merged

Conversation

Lms24
Copy link
Contributor

@Lms24 Lms24 commented Jan 15, 2025

This PR is a follow up on #10009 which ensured that the fetch function from the load event would call window.fetch so that libraries (like Sentry but there are many others) can patch it. Unfortunately, I missed back then that there's another kind of fetch request made by SvelteKit: Whenever a user navigates to a route that contains a server-load function, a request is made to fetch the server-load data.

This PR ensures that this server-load data request is also patchable by basically using the same mechanism introduced in #10009. I also added a test that would prior to this change fail.


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

Copy link

changeset-bot bot commented Jan 15, 2025

🦋 Changeset detected

Latest commit: 813f05f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

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

@Lms24 Lms24 changed the title Fix window fetch patch server load requests fix: use window.fetch for server load fetch requests Jan 15, 2025
@Rich-Harris
Copy link
Member

preview: https://svelte-dev-git-preview-kit-13315-svelte.vercel.app/

this is an automated message

@Lms24 Lms24 force-pushed the fix-window-fetch-patch-server-load-requests branch from ad6c8ef to a11834e Compare January 15, 2025 11:44
@Lms24 Lms24 changed the title fix: use window.fetch for server load fetch requests fix: use window.fetch for server load fetch requests Jan 15, 2025
Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

.changeset/funny-moles-scream.md Outdated Show resolved Hide resolved
packages/kit/src/runtime/client/client.js Outdated Show resolved Hide resolved
@dummdidumm dummdidumm merged commit f451f6c into sveltejs:main Jan 15, 2025
13 checks passed
@github-actions github-actions bot mentioned this pull request Jan 15, 2025
@Lms24
Copy link
Contributor Author

Lms24 commented Jan 15, 2025

Thanks for the quick turn around!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants