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: do not create unwanted record in history when redirecting after an invalidation #11895

Closed

Conversation

konstantinov90
Copy link

@konstantinov90 konstantinov90 commented Feb 24, 2024

Closes #11896


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 Feb 24, 2024

🦋 Changeset detected

Latest commit: 0a07b1f

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

Alexander Konstantinov added 2 commits February 25, 2024 08:56
@eltigerchino eltigerchino changed the title fix redirect after invalidate fix: do not create unwanted record in history when redirecting after an invalidation May 16, 2024
return _goto(new URL(navigation_result.location, current.url).href, {}, 1, nav_token);
return _goto(
new URL(navigation_result.location, current.url).href,
{ replaceState: true },
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if this is right. If the result is a redirect, we do want to create a history entry for the redirect. Can you can explain why you've made this change here?

Copy link
Author

Choose a reason for hiding this comment

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

No, you don't want to create a history entry, because

  1. on server redirect (302) history entry is not created, and, IMO, client side and server side navigation should be consistent
  2. when you create history entry on client redirect, you create a loop in history. I mean, for example, if you press "go back" button in your browser, browser navigates to the "redirect" entry, which instantly goes forward again, so you essentially become stuck in a loop. With server redirects such loops cannot be achieved, and neither should they be achieved on the client side

Copy link
Member

@eltigerchino eltigerchino Oct 15, 2024

Choose a reason for hiding this comment

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

I see. So we want the intermediate navigations to not create history entries. Is that correct? But the final navigation should still create a history entry?

@eltigerchino
Copy link
Member

closing this as the issue #11896 (comment) has been closed as well

@eltigerchino eltigerchino removed the request for review from dummdidumm October 15, 2024 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

redirect after invalidate creates unwanted record in history
2 participants