[GH-ISSUE #5741] Revoke all sessions doesn't invalidate useSession #10339

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

Originally created by @gossi on GitHub (Nov 3, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/5741

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

On the client in vanilla js:

  1. Register a subscriber to authClient.useSession.subscribe()
  2. Call authClient.revokeSessions()

Current vs. Expected behavior

Expected would be the useSession.subscribe() would receive a payload that the current session has been gone, but no call is made.

For example: authClient.signOut() will trigger the subscribe.

What version of Better Auth are you using?

^1.3.7

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 24.6.0: Mon Jul 14 11:28:30 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6030",
    "release": "24.6.0",
    "cpuCount": 11,
    "cpuModel": "Apple M3 Pro",
    "totalMemory": "36.00 GB",
    "freeMemory": "0.11 GB"
  },
  "node": {
    "version": "v20.19.3",
    "env": "development"
  },
  "packageManager": {
    "name": "pnpm",
    "version": "10.2.1"
  },
  "frameworks": null,
  "databases": null,
  "betterAuth": {
    "version": "^1.3.7",
    "config": null
  }
}

Which area(s) are affected? (Select all that apply)

Client

Auth config (if applicable)

import { createAuthClient } from 'better-auth/client';

export const auth = createAuthClient({
  baseURL: 'http://localhost:3000'
});

Additional context

I'm writing a better-auth adapter for ember. I've demoed it at the recent Emberfest as an example to integrate ember through vite with other libraries.

Ember has a strong reactive system, and I wrote a reactive layer around better-auth with the tools avaliable in ember right now. Ember is exploring signals based API, that would be more suited for integration with better auth.

I want to push this upstream into better-auth itself - My currentl impl. is not comparable to vue or svelte, since they use internal API, but that's ok for my experimentation.

PS. Talk still pending to be uploaded to youtube.

Originally created by @gossi on GitHub (Nov 3, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/5741 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce On the client in vanilla js: 1. Register a subscriber to `authClient.useSession.subscribe()` 2. Call `authClient.revokeSessions()` ### Current vs. Expected behavior Expected would be the `useSession.subscribe()` would receive a payload that the current session has been gone, but no call is made. For example: `authClient.signOut()` _will_ trigger the subscribe. ### What version of Better Auth are you using? ^1.3.7 ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 24.6.0: Mon Jul 14 11:28:30 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6030", "release": "24.6.0", "cpuCount": 11, "cpuModel": "Apple M3 Pro", "totalMemory": "36.00 GB", "freeMemory": "0.11 GB" }, "node": { "version": "v20.19.3", "env": "development" }, "packageManager": { "name": "pnpm", "version": "10.2.1" }, "frameworks": null, "databases": null, "betterAuth": { "version": "^1.3.7", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ```typescript import { createAuthClient } from 'better-auth/client'; export const auth = createAuthClient({ baseURL: 'http://localhost:3000' }); ``` ### Additional context I'm writing a [better-auth adapter for ember](https://github.com/ember-integrations/ember-better-auth). I've demoed it at the recent Emberfest as an example to integrate ember through vite with other libraries. Ember has a strong reactive system, and I wrote a reactive layer around better-auth with the tools avaliable in ember right now. Ember is exploring signals based API, that would be more suited for integration with better auth. I want to push this upstream into better-auth itself - My currentl impl. is not comparable to vue or svelte, since they use internal API, but that's ok for my experimentation. PS. Talk still pending to be uploaded to youtube.
GiteaMirror added the lockedbug labels 2026-04-13 06:24:11 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Nov 3, 2025):

Hello there! It appears that revokeSessions isn’t updating your session subscribers as expected. In our current implementation, signing out triggers an immediate session update, but revoking sessions may bypass the internal state update that's normally observed by subscribers. As a next step, please double-check that your client isn’t caching an outdated session. It might also help to try signing out (which does trigger the update) and then compare the outcomes. If you’re still experiencing issues, we’d appreciate additional logs or a minimal repro to help our team pinpoint the problem. Could you share a bit more about your setup or any error logs? tag @better-auth-agent

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3481864948 --> @better-auth-agent[bot] commented on GitHub (Nov 3, 2025): Hello there! It appears that revokeSessions isn’t updating your session subscribers as expected. In our current implementation, signing out triggers an immediate session update, but revoking sessions may bypass the internal state update that's normally observed by subscribers. As a next step, please double-check that your client isn’t caching an outdated session. It might also help to try signing out (which does trigger the update) and then compare the outcomes. If you’re still experiencing issues, we’d appreciate additional logs or a minimal repro to help our team pinpoint the problem. Could you share a bit more about your setup or any error logs? tag @better-auth-agent <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) • [Discord](https://discord.gg/better-auth) • [GitHub](https://github.com/better-auth/better-auth) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/better-auth) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/better-auth/better-auth)
Author
Owner

@dosubot[bot] commented on GitHub (Nov 3, 2025):

Hi @gossi! I'm Dosu and I’m helping the better-auth team.

The reason revokeSessions() doesn't trigger useSession.subscribe() updates is that Better Auth's useSession is a React/Vue hook and doesn't expose a subscribe method for vanilla JS—this is a documentation mistake, and no such API exists at runtime or in types. Only signOut() is wired to trigger session state updates that notify subscribers in supported frameworks. There is currently no vanilla JS subscription API for session changes outside of hooks, so session state changes from revokeSessions() won't propagate automatically to your reactive layer or Ember integration reference.

The recommended workaround is to bridge session state from the hook into your own state layer (for example, using a custom context provider or polling after revocation). For non-React/Vue environments, you'll need to manually refetch or synchronize session state after calling revokeSessions(). This gap is known and relevant for pushing upstream improvements, especially for frameworks like Ember that expect strong reactivity reference.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3481878602 --> @dosubot[bot] commented on GitHub (Nov 3, 2025): <!-- Greeting --> Hi @gossi! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> The reason revokeSessions() doesn't trigger useSession.subscribe() updates is that Better Auth's useSession is a React/Vue hook and doesn't expose a subscribe method for vanilla JS—this is a documentation mistake, and no such API exists at runtime or in types. Only signOut() is wired to trigger session state updates that notify subscribers in supported frameworks. There is currently no vanilla JS subscription API for session changes outside of hooks, so session state changes from revokeSessions() won't propagate automatically to your reactive layer or Ember integration [reference](https://github.com/better-auth/better-auth/issues/4879). The recommended workaround is to bridge session state from the hook into your own state layer (for example, using a custom context provider or polling after revocation). For non-React/Vue environments, you'll need to manually refetch or synchronize session state after calling revokeSessions(). This gap is known and relevant for pushing upstream improvements, especially for frameworks like Ember that expect strong reactivity [reference](https://github.com/better-auth/better-auth/issues/4879). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/0d85137f-3ec9-4883-88a2-bc9efa18455e?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/0d85137f-3ec9-4883-88a2-bc9efa18455e?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/0d85137f-3ec9-4883-88a2-bc9efa18455e?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/0d85137f-3ec9-4883-88a2-bc9efa18455e?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/0d85137f-3ec9-4883-88a2-bc9efa18455e?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/0d85137f-3ec9-4883-88a2-bc9efa18455e?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/0d85137f-3ec9-4883-88a2-bc9efa18455e?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/5741)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#10339