Skip to content

SessionProvider sends many requests to retrieve the session #10244

Closed
@srinesha

Description

@srinesha

Environment

  System:
    OS: Linux 6.1 NixOS 23.11 (Tapir) 23.11 (Tapir)
    CPU: (12) x64 12th Gen Intel(R) Core(TM) i7-1255U
    Memory: 8.62 GB / 15.34 GB
    Container: Yes
    Shell: 5.9 - /run/current-system/sw/bin/zsh
  Binaries:
    Node: 21.6.2 - ~/.nix-profile/bin/node
    npm: 10.2.4 - ~/.nix-profile/bin/npm
    pnpm: 8.15.3 - ~/.nix-profile/bin/pnpm
  Browsers:
    Chromium: 122.0.6261.94
  npmPackages:
    next: 14.1.2 => 14.1.2
    next-auth: 5.0.0-beta.15 => 5.0.0-beta.15
    react: ^18 => 18.2.0

Reproduction URL

https://github.com/srinesha/nextjs-testing

Describe the issue

I have setup credential provider authentication. When SessionProvider is added in the layout, one page reload sends around 5 requests to retrieve the session even though useSession is never used anywhere in the application.

SessionProvider in layout.tsx:
https://github.com/srinesha/nextjs-testing/blob/ec5d831cd926fd86f9f0b1952df91829034ba4c3/app/settings/layout.tsx#L10C1-L14C23

2024-03-08.06-16-56ccc.mp4

How to reproduce

https://github.com/srinesha/nextjs-testing

  1. Clone the repository
  2. Install dependencies pnpm install
  3. Run pnpm dev
  4. Go to localhost:3000/auth/login
  5. Enter any random email address
  6. Click on submit
  7. When loading the settings page, there will be many requests to get the session

Expected behavior

Send one request per page load?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageUnseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions