Skip to content

Parallel / Intercepting Route (Modal) won't close until Server Action completes #64432

@steve-marmalade

Description

@steve-marmalade

Link to the code that reproduces this issue

https://github.com/marmalade-labs/nextgram

To Reproduce

  1. Navigate to deployed application: https://nextgram-sigma.vercel.app/
  2. Click a card to open a modal
  3. Press the "Submit" button (which triggers a server action with a 5 second sleep)
  4. Immediately try to close the modal by clicking the X

The diff against the "official" nextgram repo is pretty small: marmalade-labs/nextgram@9a1e69d

Current vs. Expected behavior

I expected the modal to close immediately, and for the server action to continue running in the background. Instead, the URL bar updates immediately, but the modal itself stays open until the server action completes.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Fri, 05 Apr 2024 00:14:23 +0000
  Available memory (MB): 31886
  Available CPU cores: 8
Binaries:
  Node: 18.18.2
  npm: 10.5.1
  Yarn: 1.22.22
  pnpm: 8.15.5
Relevant Packages:
  next: 14.2.1-canary.3 // Latest available version is detected (14.2.1-canary.3).
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.4.5
Next.js Config:
  output: N/A

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

App Router, Routing (next/router, next/navigation, next/link)

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

next dev (local), next start (local), Vercel (Deployed)

Additional context

The current situation makes it hard to use optimistic updates along with server actions + modals, because the user gets the immediate feedback that the action succeeded and naturally tries to close the modal soon after, which results in the app "hanging" until the server action completes and the router can catch up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Linking and NavigatingRelated to Next.js linking (e.g., <Link>) and navigation.bugIssue was opened via the bug report template.locked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions