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

[history] BrowserHistory: Loaded wrong state #369

Closed
alexkazik opened this issue Sep 8, 2023 · 2 comments · Fixed by #391
Closed

[history] BrowserHistory: Loaded wrong state #369

alexkazik opened this issue Sep 8, 2023 · 2 comments · Fixed by #391
Labels
bug Something isn't working

Comments

@alexkazik
Copy link
Contributor

Describe the Bug

It's possible that a wrong state is loaded.

Steps to Reproduce

  1. View the website, url for page A, use replace_with_state to set the state for this page, this created state id=0
  2. Go to page B with push_with_state, this created state id=1
  3. Reload the current page B, this will again "use replace_with_state to set the state for this page, this created state id=0"
  4. Go back, this will go the the url of page A, JS will return state id 0 and thus state 0 is used (which was created for page B)

Expected Behavior

There should be no state found when going back.

Additional Context

It can be "fixed" by starting the id (crates/history/src/utils.rs:7) not at 0 but at a more or less random point.
One alternative to an actual random number would be to use window.performance.now().hash().

But since MemoryHistory also uses the id system it may have to be split to not bring web-sys dependencied into MemoryHistory.

I can try to write a PR for it, if this is something that is wanted.

@alexkazik alexkazik added the bug Something isn't working label Sep 8, 2023
@ranile
Copy link
Collaborator

ranile commented Oct 4, 2023

Sorry for the late reply. PRs are always welcome!

@alexkazik
Copy link
Contributor Author

I'll write one, but will take about a week.

futursolo pushed a commit that referenced this issue Oct 14, 2023
* Update Cargo.lock

* (history): Use a different starting id each time (#369)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants