Skip to content

fix: ensure store updates go through scheduler during SPA navigation #7725

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

naaa760
Copy link

@naaa760 naaa760 commented Jul 13, 2025

Hey, I just made a Pull Request!

#7720

What is it?

  • Bug

Description

Fixes useTask being executed for wrong path after SPA navigation due to store updates not going through scheduler properly. Added untrack() around store mutations in QwikCityProvider to ensure correct scheduling.

  • Solution

  • Added untrack() around all store mutations to ensure they go through Qwik's scheduler properly

  • Fixed store updates for:

  • routeLocation (url, params, isNavigating)

  • content (headings, menu)

  • documentHead (links, meta, styles, etc.)

Testing:

  • The fix can be verified by:
  • Creating a component that uses useTask$ with useLocation()
  • Performing SPA navigation between routes
  • Verifying that the task executes with the correct path

@naaa760 naaa760 requested a review from a team as a code owner July 13, 2025 17:38
Copy link

changeset-bot bot commented Jul 13, 2025

⚠️ No Changeset found

Latest commit: cc71d6b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@@ -291,7 +292,9 @@ export const QwikCityProvider = component$<QwikCityProps>((props) => {
}

actionState.value = undefined;
routeLocation.isNavigating = true;
untrack(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Can't you put all the assignments into a single untrack?

Copy link
Author

Choose a reason for hiding this comment

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

You are right @wmertens !
I fixed the SPA navigation bug by implementing a single untrack() block for all store mutations, ensuring proper scheduling and preventing unnecessary re-executions during navigation.

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.

2 participants