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

Production build call data fetching function twice (server components, app directory) #44966

Open
1 task done
havran opened this issue Jan 17, 2023 · 3 comments
Open
1 task done
Labels
template: bug A user has filled out the bug report template. Issue needs triaging

Comments

@havran
Copy link

havran commented Jan 17, 2023

Verify canary release

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

Provide environment information

    Operating System:
      Platform: linux
      Arch: x64
      Version: #1 SMP Wed Nov 23 01:01:46 UTC 2022
    Binaries:
      Node: 16.19.0
      npm: 9.3.0
      Yarn: 1.22.19
      pnpm: N/A
    Relevant packages:
      next: 13.1.3-canary.2
      eslint-config-next: 13.1.2
      react: 18.2.0
      react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

App directory (appDir: true), Data fetching (gS(S)P, getInitialProps)

Link to the code that reproduces this issue

https://github.com/havran/nextjs-13.1.2-called-twice

To Reproduce

Steps:

  • build
npm run build
npm run start
  • click to link and observe console

Describe the Bug

When I run production build, my data fetching method is called twice (based by observation of console.time method).
When I run app as dev, this behave as expected, data fetching method is called once.

Expected Behavior

Data fetching method should be called once with production build.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

next start

@havran havran added the template: bug A user has filled out the bug report template. Issue needs triaging label Jan 17, 2023
@Rishab49
Copy link

Rishab49 commented Jan 17, 2023

Do you tried turning off react strict mode in config file
const nextConfig = { reactStrictMode: false }

refer to the solution of this issue #35822 (comment)

@havran
Copy link
Author

havran commented Jan 17, 2023

Do you tried turning off react strict mode in config file const nextConfig = { reactStrictMode: false }

refer to the solution of this issue #35822 (comment)

It is not related - we talking about SSR here. And I try it, for to be sure and not help.

@havran
Copy link
Author

havran commented Jan 18, 2023

Tested with canary v13.1.3-canary.4 - same behaviour.

@havran havran changed the title Production build call data fetching function twice (app directory) Production build call data fetching function twice (server components, app directory) Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
template: bug A user has filled out the bug report template. Issue needs triaging
Projects
None yet
Development

No branches or pull requests

2 participants