Skip to content

fix(app-router): discard queued server actions on navigation#91044

Open
anujboddu wants to merge 1 commit intovercel:canaryfrom
anujboddu:fix/90467-canonicalurl-race
Open

fix(app-router): discard queued server actions on navigation#91044
anujboddu wants to merge 1 commit intovercel:canaryfrom
anujboddu:fix/90467-canonicalurl-race

Conversation

@anujboddu
Copy link

What?

Discard all queued server actions when a navigation/restore is dispatched so stale queued actions cannot commit state after a route change.

Why?

Issue #90467 reports queued server actions racing with navigation and clobbering state.canonicalUrl (and related router state). Previously only the currently pending action was discarded; queued actions could still run after navigation and overwrite the new route state.

How?

  • Mark every queued action as discarded when a navigation/restore is dispatched.
  • Keep the navigation action as the last queued action so subsequent actions queue behind it.
  • Added an e2e regression test that queues multiple actions, navigates away, and asserts we remain on the destination page.

Fixes #90467

Tests

  • pnpm lint-eslint packages/next/src/client/components/app-router-instance.ts test/e2e/app-dir/actions/app-action.test.ts
  • Unable to run pnpm testonly-start-webpack ... locally because packages/next/dist/build/jest/jest was missing (build not generated in this environment).

@nextjs-bot
Copy link
Collaborator

Allow CI Workflow Run

  • approve CI run for commit: 37a5c9d

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Race condition results in multiple threads working on server action queue, corrupting state.canonicalUrl

2 participants