next.js icon indicating copy to clipboard operation
next.js copied to clipboard

cache() not work when upgrade from [email protected] to next@^13.0.2

Open phamqthanh opened this issue 2 years ago • 3 comments

Verify canary release

  • [X] 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 21.4.0: Mon Feb 21 20:36:53 PST 2022; root:xnu-8020.101.4~2/RELEASE_ARM64_T8101 Binaries: Node: 16.13.1 npm: 8.14.0 Yarn: 1.22.17 pnpm: 7.15.0 Relevant packages: next: 13.0.3 eslint-config-next: 13.0.0 react: 18.2.0 react-dom: 18.2.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

All function wrapped by cache work fine on next version 13.0.0, after upgrade from version 13.0, function use from both request in layout and page are two separate request.

Expected Behavior

response for same request cached when use cache

Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster

no link

To Reproduce

  1. Create function wrapped by cache and put log inside.
  2. use function wrapped by cache more than one in server component.
  3. so many function called, as many log print

phamqthanh avatar Nov 12 '22 11:11 phamqthanh

I'm seeing the same with next 13.0.3 and react 18.2.0.

mpereira avatar Nov 17 '22 21:11 mpereira

Locking Next to version 13.0.0 and 13.0.1 works, 13.0.2 and up seem not to cache any of my server side fetches.

elbojoloco avatar Nov 18 '22 09:11 elbojoloco

https://codesandbox.io/p/sandbox/romantic-oskar-5scorz

Here is a basic example using next 13.0.2, check the output console. When loading the home page, the api console log is logged twice.

elbojoloco avatar Nov 18 '22 09:11 elbojoloco

I think this is fixed in 13.0.6, can someone help verify?

Rathpanha avatar Dec 02 '22 10:12 Rathpanha

I think this is fixed in 13.0.6, can someone help verify?

Works for:

Operating System: Win10
Node: 16.13.0
npm: 8.5.1
Yarn: 1.22.17
pnpm: 7.16.1
Relevant packages:
next: 13.0.6
eslint-config-next: 13.0.4
react: 18.2.0
react-dom: 18.2.0

Pasalietis avatar Dec 06 '22 17:12 Pasalietis