Skip to content

fix: prevent endless SPA 404 loop #11354

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

Merged
merged 6 commits into from
Dec 18, 2023
Merged

fix: prevent endless SPA 404 loop #11354

merged 6 commits into from
Dec 18, 2023

Conversation

eltigerchino
Copy link
Member

@eltigerchino eltigerchino commented Dec 16, 2023

fixes #11227

This PR reverts the changes in #11025 that reloaded the page when fetching data failed. Now, it just avoids parsing the response body if it's not JSON and returns the same HttpError with a simplified error message based on the status (we have been doing the same in the server). No test unless we want to setup a new test suite without a root error load function to reproduce the issue.

quick reproduction: https://github.com/eltigerchino/sveltekit-bug-11227

  1. Run pnpm i && pnpm dev
  2. Navigate to a non-existent page /example
  3. See the endless refresh loop

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:.

Sorry, something went wrong.

Copy link

changeset-bot bot commented Dec 16, 2023

🦋 Changeset detected

Latest commit: 9936f5a

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

@benmccann
Copy link
Member

Perhaps we could add a test that would fail without this change? I think we've got a couple test apps that use a fallback page

@eltigerchino
Copy link
Member Author

I ended up creating a new test app because many of the other ones rely on ssr being enabled. This test specifically requires SSR to be disabled in the root layout so that the error page isn't server-side rendered.

@benmccann benmccann merged commit ca5d5ec into master Dec 18, 2023
@benmccann benmccann deleted the fix-endless-default-error branch December 18, 2023 03:56
@benmccann
Copy link
Member

thank you!

@github-actions github-actions bot mentioned this pull request Dec 18, 2023
caleb531 added a commit to caleb531/personal-website that referenced this pull request Dec 18, 2023
Including several fixes for a serious 404 bug in SvelteKit. See:
<sveltejs/kit#11354>
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.

ssr false with +layout.server file cause loop page refresh on 404 (#6854 recurred)
2 participants