Skip to content

Transition deadlock when navigating and double calling server action #84299

Closed

Description

@denk0403

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/next-js-transition-starvation-kpl45h

To Reproduce

  1. Start the application in development or production.
  2. Open the network tab in the browser devtools.
  3. Click the button on the home page. This will start a transition which pushes a new path and then awaits a server action.
  4. Once the server action has started pending and has not completed yet, click the button again.
Image

Current vs. Expected behavior

Current Behavior:

  • The navigation never completes and the second action is dropped (not visible in the network tab).
  • Subsequent presses to the button also do not navigate, indicating the application is in a transition deadlock.
Screen.Recording.2025-09-27.at.4.11.29.PM.mov

Expected behavior:

  • Both actions should fire from the home page, and once both complete, the navigation should occur.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
  Available memory (MB): 4102
  Available CPU cores: 2
Binaries:
  Node: 20.9.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 15.6.0-canary.5 // There is a newer canary version (15.6.0-canary.32) available, please upgrade! 
  eslint-config-next: N/A
  react: 19.1.1
  react-dom: 19.1.1
  typescript: 5.3.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Server Actions

Which stage(s) are affected? (Select all that apply)

next dev (local), next start (local)

Additional context

I tested various older versions of Next.js, and I believe this was introduced in v15.2.2. I suspect PR #75362 is related to the issue.

NEXT-4733

Activity

  1. added theissue type on Sep 27, 2025
  2. added
    Server Actions
    on Sep 27, 2025
  3. added
    linear: next
    on Oct 1, 2025
  4. Suhaib3100 commented on Jan 29, 2026

    @Suhaib3100
    Contributor

    Root Cause Analysis

    I've investigated this issue and identified the root cause in the action queue logic.

    The Issue:
    When a navigation action is dispatched while a server action is pending, the pending action is correctly marked as discarded. However, the discarded action's promise is never resolved within the handleResult function. The function returns early without calling action.resolve(), which leaves the React transition hanging indefinitely and causes the deadlock.

    Relevant Code:
    The issue is located in app-router-instance.ts:

    function handleResult(nextState: AppRouterState) {
      if (action.discarded) {
        // ... handles revalidation flag
        runRemainingActions(actionQueue, setState)
        return  // ❌ BUG: Promise never resolved!
      }
      // ...
      action.resolve(nextState)  // ← Only reached if not discarded
    }

    The Fix:
    Discarded actions should still resolve their promises (using the current state) even if the result is discarded. This ensures the React transition completes successfully without applying the stale state update.

    I am working on a PR to implement this fix now. This should also address related issue #86055.

  5. gaearon commented on Jul 2, 2026

    @gaearon
    Contributor

    This should get fixed by #95391.

  6. gaearon commented on Jul 3, 2026

    @gaearon
    Contributor

    Confirmed this is fixed in 16.3.0-canary.76.

  7. github-actions commented on Sep 7, 2026

    @github-actions
    Contributor

    This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

  8. locked as resolved and limited conversation to collaborators on Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Server Actionslinear: nextlocked

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions