[GH-ISSUE #9182] tracking: stateless sessions (account_data lifecycle, getAccessToken refresh) #28623

Open
opened 2026-04-17 20:03:19 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @gustavovalverde on GitHub (Apr 14, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/9182

Summary

Stateless mode uses cookie-based session data, and two failures recur in that path. Account lookup can fail because the cookie cache does not retain the data needed for later account resolution. Access-token refresh can also succeed internally without returning the updated cookie or token to the client. A server-side auth.api.accountInfo request depends on the same account lookup path.

Root cause

The failures sit in linked but separate code paths. In the account lookup path, parseUserOutput filters id out of the data written to setCookieCache, and the account_data cookie lifecycle does not refresh when expected. In the token refresh path, getAccessToken calls getSessionFromCtx with returnHeaders: false, which drops the inner set-cookie header. The refreshed token can be written internally but not propagated back to the caller. That propagation gap likely overlaps with the session cookie cache tracker.

Scope

In: stateless session account lookup, cookie-cache id stripping, account_data refresh semantics, auth.api.getAccessToken refresh path, auth.api.accountInfo server-side ask.

Out: DB-backed cookie-cache lifecycle (see tracking: session cookie cache). JWKS rotation defaults (out of this tracker; flag separately if needed).

Resolution criteria

  • Stateless sessions retrieve the account on every lookup without "Account not found".
  • getAccessToken refreshes and propagates the new token to the client in both cookie and response, across Cognito, generic OAuth, and Twitch.
  • auth.api.accountInfo is available server-side with the same contract as the client API.
  • Likely shared upstream with tracking: session cookie cache through the getSessionFromCtx set-cookie propagation path.
  • Prior closed context: #6252, #6447, #6372 (account lookup); #6215, #7416 (JWT defaults, adjacent not subsumed).
Originally created by @gustavovalverde on GitHub (Apr 14, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/9182 ## Summary Stateless mode uses cookie-based session data, and two failures recur in that path. Account lookup can fail because the cookie cache does not retain the data needed for later account resolution. Access-token refresh can also succeed internally without returning the updated cookie or token to the client. A server-side `auth.api.accountInfo` request depends on the same account lookup path. ## Root cause The failures sit in linked but separate code paths. In the account lookup path, `parseUserOutput` filters `id` out of the data written to `setCookieCache`, and the `account_data` cookie lifecycle does not refresh when expected. In the token refresh path, `getAccessToken` calls `getSessionFromCtx` with `returnHeaders: false`, which drops the inner `set-cookie` header. The refreshed token can be written internally but not propagated back to the caller. That propagation gap likely overlaps with the session cookie cache tracker. ## Scope **In:** stateless session account lookup, cookie-cache `id` stripping, `account_data` refresh semantics, `auth.api.getAccessToken` refresh path, `auth.api.accountInfo` server-side ask. **Out:** DB-backed cookie-cache lifecycle (see `tracking: session cookie cache`). JWKS rotation defaults (out of this tracker; flag separately if needed). ## Resolution criteria - Stateless sessions retrieve the account on every lookup without "Account not found". - `getAccessToken` refreshes and propagates the new token to the client in both cookie and response, across Cognito, generic OAuth, and Twitch. - `auth.api.accountInfo` is available server-side with the same contract as the client API. ## Related - Likely shared upstream with `tracking: session cookie cache` through the `getSessionFromCtx` set-cookie propagation path. - Prior closed context: #6252, #6447, #6372 (account lookup); #6215, #7416 (JWT defaults, adjacent not subsumed).
GiteaMirror added the trackingcorebug labels 2026-04-17 20:03:19 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#28623