Skip to content

Conversation

@conradkirschner
Copy link
Contributor

#334 is an interessting bug, which could be tackled in different ways. This PR should resolve the bug (dirty fix)

Calling router.refresh will trigger a re-render of the server component and drop the client cache completly.
It seems to fix the bug, but needs better testing - therefore it is just a draft for now.

Preferable I would like to add an optimistic mutation handling here, but avoid implementing it by my own.

Libs that have these feature implemented are:
-> tanstack query - https://tanstack.com/query/latest/docs/framework/react/overview
or
-> swr - https://swr.vercel.app/

Alternative
Usage of nextjs fetch tagging system, but requires a bit strategy planing (example tag: project_list_<org_id>, the api mutation request get called on server side & invalidates project_list_<org_id> then redirect to the project list page which tne re-fetches the project list (other fetch data stays cached, as not changed).
Result should feel similar to a client side app

- This is a workaround fix to avoid nextjs caching heuristics, until we have a proper caching re-validation strategy
@harry-rhesis harry-rhesis added the Projects Issues related to functionality around projects label Oct 27, 2025
@harry-rhesis harry-rhesis added this to the Release 8 (ETA 31.10) milestone Oct 27, 2025
@harry-rhesis harry-rhesis marked this pull request as ready for review October 27, 2025 09:55
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

// Navigate to the projects page
router.push('/projects');
// invalidate cache by force
router.refresh();
Copy link

Choose a reason for hiding this comment

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

Bug: Router Operations Timing Conflict

Race condition between router.push() and router.refresh(). Both are asynchronous operations called synchronously without awaiting. This creates a timing issue where router.refresh() may execute before the navigation completes, potentially refreshing the wrong page (current page instead of the target /projects page) or interfering with the navigation itself. The operations should be ordered with proper async handling to ensure router.push() completes before router.refresh() executes.

Fix in Cursor Fix in Web

@harry-rhesis harry-rhesis self-requested a review November 3, 2025 15:19
@harry-rhesis harry-rhesis marked this pull request as draft November 3, 2025 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects Issues related to functionality around projects

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants