Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revalidateTag inside dynamic parallel route slot does not work as expected #64517

Closed
beckerei opened this issue Apr 15, 2024 · 1 comment · Fixed by #64532
Closed

revalidateTag inside dynamic parallel route slot does not work as expected #64517

beckerei opened this issue Apr 15, 2024 · 1 comment · Fixed by #64532
Labels
bug Issue was opened via the bug report template. locked

Comments

@beckerei
Copy link

Link to the code that reproduces this issue

https://codesandbox.io/p/sandbox/cool-resonance-hmp58x

To Reproduce

  1. build & start
  2. navigate to /foo via link (dynamic)
  3. click button "revalidate Tag"

Current vs. Expected behavior

The resource associated with the tag has not been updated.
I'm expected the resource to be updated.

Downgrading next to 14.1.0 in the provided example fixes the problem.

This may only apply to the dev server:
Sometimes the resource seems to be updated when a certain time has passed (30sec?), but to me the pattern is random.
You can also sometimes see different cached data between the two routes (I expect this to be because we have a page and a catchall page in the main slot - optional cache all does not work, this is why it's duplicated)

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: 14.2.1 // Latest available version is detected (14.2.1).
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.1.3
Next.js Config:
  output: N/A

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

App Router

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

next dev (local), next start (local)

Additional context

We upgraded our application to 14.2.0 only to see that our revalidation no longer has any effect, but we also can't really downgrade since we before got occosionally/reproducible blank pages that have been fixed in the release.

I'm currently setting experimental.staleTimes.dynamic to 0 as a hot-fix, but it's also not helping all of time.

We usually have a redirect after the action, but for some other actions the resource is being updated without a redirect afterwards, in these cases it seems that the revalidation works as before.

Our app folder structure is similar as in the provided example this is why I adapted it.
We have a main page that has paginated content and the parallel route slot can render a sidepanel containing additional information where some things can also be updated. Updated data needs to be reflected in the panel as well as the main slot.

@beckerei beckerei added the bug Issue was opened via the bug report template. label Apr 15, 2024
ztanner added a commit that referenced this issue Apr 16, 2024
When an action is marked as "discarded", we enqueue a refresh, since the
navigation event will be invoked immediately without waiting for the
action to finish. We refresh because it's possible that the discarded
action triggered some sort of mutation/revalidation, and we want the
router to still be able to respond to that new data.

However there's a bug in this logic -- it'll only enqueue the refresh
action if there were no other actions in the queue, ignoring the case
where something is still in the queue. This makes sure that the refresh
is handled after `runRemainingActions` finishes.

When adding a test for the server component case (which doesn't hit this
refresh branch), I noticed `LayoutRouter` caused React to suspend
indefinitely, because it got stuck in the `use(unresolvedThenable)`
case. We should only suspend indefinitely if we kicked off a the
`SERVER_PATCH` action, as otherwise it's possible nothing will ever
break out of that branch.

Fixes #64517
Closes NEXT-3124
ztanner added a commit that referenced this issue Apr 17, 2024
When an action is marked as "discarded", we enqueue a refresh, since the
navigation event will be invoked immediately without waiting for the
action to finish. We refresh because it's possible that the discarded
action triggered some sort of mutation/revalidation, and we want the
router to still be able to respond to that new data.

However there's a bug in this logic -- it'll only enqueue the refresh
action if there were no other actions in the queue, ignoring the case
where something is still in the queue. This makes sure that the refresh
is handled after `runRemainingActions` finishes.

When adding a test for the server component case (which doesn't hit this
refresh branch), I noticed `LayoutRouter` caused React to suspend
indefinitely, because it got stuck in the `use(unresolvedThenable)`
case. We should only suspend indefinitely if we kicked off a the
`SERVER_PATCH` action, as otherwise it's possible nothing will ever
break out of that branch.

Fixes #64517
Closes NEXT-3124
Copy link
Contributor

github-actions bot commented May 1, 2024

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.

@github-actions github-actions bot added the locked label May 1, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. locked
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant