[GH-ISSUE #604] Session does not refresh everytime when updateAge is explicitly set to 0 #8337

Closed
opened 2026-04-13 03:24:32 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @Sebbev on GitHub (Nov 20, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/604

Describe the bug
The updateAge option on the session options does not correctly handle 0 as a valid value, defaulting to the fallback value instead.

As describe in the type description it should allow for a 0 value to refresh every time it is used.

a50fce1561/packages/better-auth/src/types/options.ts (L293-L299)

To Reproduce
Steps to reproduce the behavior:

  1. Set updateAge to 0 in auth session options.
  2. Use the session in any way.
  3. expiresAt is not updated in DB.

Expected behavior
Update the expiresAt in the database whenever accessing the session.

Desktop (please complete the following information):

  • OS: Ubuntu
  • Browser Chrome
  • Version 131.0.6778.85

Additional context
Could probably be fixed by just changing || to ?? on this line:
a50fce1561/packages/better-auth/src/init.ts (L87)

There might also be more similar issues elsewhere.

Originally created by @Sebbev on GitHub (Nov 20, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/604 **Describe the bug** The `updateAge` option on the session options does not correctly handle 0 as a valid value, defaulting to the fallback value instead. As describe in the type description it should allow for a 0 value to refresh every time it is used. https://github.com/better-auth/better-auth/blob/a50fce1561137b0ac506eb88a29e8604cd72c454/packages/better-auth/src/types/options.ts#L293-L299 **To Reproduce** Steps to reproduce the behavior: 1. Set `updateAge` to `0` in auth session options. 2. Use the session in any way. 3. `expiresAt` is not updated in DB. **Expected behavior** Update the `expiresAt` in the database whenever accessing the session. **Desktop (please complete the following information):** - OS: Ubuntu - Browser Chrome - Version 131.0.6778.85 **Additional context** Could probably be fixed by just changing `||` to `??` on this line: https://github.com/better-auth/better-auth/blob/a50fce1561137b0ac506eb88a29e8604cd72c454/packages/better-auth/src/init.ts#L87 There might also be more similar issues elsewhere.
GiteaMirror added the locked label 2026-04-13 03:24:32 -05:00
Author
Owner

@Bekacru commented on GitHub (Nov 20, 2024):

fixed on v1.0.0-canary.8

<!-- gh-comment-id:2489475417 --> @Bekacru commented on GitHub (Nov 20, 2024): fixed on `v1.0.0-canary.8`
Author
Owner

@Bekacru commented on GitHub (Nov 20, 2024):

feel free to re-open if not

<!-- gh-comment-id:2489476234 --> @Bekacru commented on GitHub (Nov 20, 2024): feel free to re-open if not
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8337