-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Description
Link to the code that reproduces this issue
https://github.com/marmalade-labs/nextgram
To Reproduce
- Navigate to deployed application: https://nextgram-sigma.vercel.app/
- Click a card to open a modal
- Press the "Submit" button (which triggers a server action with a 5 second sleep)
- 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/AWhich 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.