Skip to content

Fix throw render() history nav - #96

Merged
dajinchu merged 2 commits into
masterfrom
dc/fix-abort-history-nav
Aug 5, 2026
Merged

Fix throw render() history nav#96
dajinchu merged 2 commits into
masterfrom
dc/fix-abort-history-nav

Conversation

@dajinchu

@dajinchu dajinchu commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

When making a history navigation to a route that calls throw render() we call historyPoppedToLocationWithRestorationIdentifier twice, once on the original visit and again on each abort-render. This triggers two turbolinks:visit events and causes multiple Visits to be created, rather than updating redirectedToLocation on the existing Visit. This breaks Turbolinks invariant which may lead to bugs on the mobile app and race conditions.

}
// Initially, currentVisit was just created by historyPoppedToLocationWithRestorationIdentifier
// If abort rendering, we'd rather Vike pass _turbolinksVisit, but it does not, so we recover from Turbolinks global
// There is risk of race condition if a history nav and a regular nav happen at the same time.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This solution remains imperfect. We need to open a Vike feature request. onBeforeRoute is a bit of a hack in general.

@dajinchu
dajinchu merged commit 59ca59a into master Aug 5, 2026
2 checks passed
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.

1 participant