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

Requests are not automatically deduped (Request Memoization) #57619

Closed
1 task done
yarikpetrenko opened this issue Oct 27, 2023 · 3 comments
Closed
1 task done

Requests are not automatically deduped (Request Memoization) #57619

yarikpetrenko opened this issue Oct 27, 2023 · 3 comments
Labels
bug Issue was opened via the bug report template. locked Pages Router Related to Pages Router.

Comments

@yarikpetrenko
Copy link

yarikpetrenko commented Oct 27, 2023

Link to the code that reproduces this issue

https://codesandbox.io/p/sandbox/gallant-tree-4yxvwz

To Reproduce

  1. Start the dev server
  2. Refresh page
  3. You see 2 messages "hit" in the console (when you should see only one)

Current vs. Expected behavior

  1. Start the dev server
  2. Refresh page
  3. Only one message "hit" is displayed

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:43 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T6000
Binaries:
  Node: 18.18.2
  npm: 9.8.1
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.0.1-canary.0
  eslint-config-next: 13.4.13
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: N/A

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

Data fetching (gS(S)P, getInitialProps)

Additional context

After updating my project to next.js version 13.5.5 I started seeing that my Node.js (express )server returns a lot of 429 responses as I set rate limiting for all routes. After further investigation I discovered that starting from 13.5.5 fetch requests does not get deduped even when documentation says it should.

Passing data between a parent layout and its children is not possible. However, you can fetch the same data in a route more than once, and React will automatically dedupe the requests without affecting performance.

And this issue preserved on all versions above. Interesting thing is that when my local project on Next version 13.5.4 works fine and request get deduped, when I installed 13.5.4 on the codesandbox it didn't change anything.

On my opinion this is one of the most important features for app router so it's strange it doesn't work, and I'm worried that even it works fine with 13.5.4 on my local server it may not work on the production as it doesn't work with codesandbox.

@yarikpetrenko yarikpetrenko added the bug Issue was opened via the bug report template. label Oct 27, 2023
@github-actions github-actions bot added the Pages Router Related to Pages Router. label Oct 27, 2023
@yarikpetrenko yarikpetrenko changed the title Fetch doesn't automatically dedupe the requests Requests are not automatically deduped (Request Memoization) Nov 1, 2023
@OlegLustenko
Copy link

OlegLustenko commented Nov 1, 2023

Unfortunately this is a know issue, attaching as duplicate

#52126

@yarikpetrenko
Copy link
Author

Closed as duplicate in favour of #52126

Copy link
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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 16, 2023
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 Pages Router Related to Pages Router.
Projects
None yet
Development

No branches or pull requests

2 participants