#9139·next-auth

Network error cause the session in application become to null and never refetch again

Author: BrooooooklynCreated Nov 14, 2023Updated Aug 6, 2026
Labelsbugtriage

Environment

System:
    OS: Windows 10 10.0.22631
    CPU: (32) x64 AMD Ryzen 9 5950X 16-Core Processor
    Memory: 47.28 GB / 63.92 GB
  Binaries:
    Node: 18.18.2 - ~\AppData\Local\fnm_multishells\5048_1699970090223\node.EXE
    Yarn: 4.0.1 - ~\AppData\Local\fnm_multishells\5048_1699970090223\yarn.CMD
    npm: 9.8.1 - ~\AppData\Local\fnm_multishells\5048_1699970090223\npm.CMD

npmPackages:
    react: 18.2.0 => 18.2.0
    next-auth: ^4.23.2 => 4.23.2

npmPackages:
    @auth/prisma-adapter: ^1.0.3 => 1.0.4

Reproduction URL

https://github.com/nextauthjs/next-auth-example

Describe the issue

Network error causes the session in the application to become null and never refetch again.

How to reproduce

  • enable refetchOnWindowFocus
  • disable the network in devtool
  • blur and focus the tab
  • re-enable the network
  • application session becomes null, and never updates again even calling the update

Expected behavior

refetch the session if the __NEXTAUTH._session comes from the network error: https://github.com/nextauthjs/next-auth/blob/465e882176de5c9e1bc5a482c429ba8d54c55e22/packages/next-auth/src/react.tsx#L395