Skip to content

docs(auth): surface global-scope warning on signOut JSDoc#2269

Merged
mandarini merged 2 commits intosupabase:developfrom
MukundaKatta:docs/auth-signout-warn-global
Apr 28, 2026
Merged

docs(auth): surface global-scope warning on signOut JSDoc#2269
mandarini merged 2 commits intosupabase:developfrom
MukundaKatta:docs/auth-signout-warn-global

Conversation

@MukundaKatta
Copy link
Copy Markdown
Contributor

🔍 Description

What changed?

Reworked the JSDoc on GoTrueClient.signOut so the default scope: 'global' is impossible to miss:

  • Added a ⚠️ warning callout directly under the one-liner description noting that the default signs out every device and pointing at { scope: 'local' } as the common choice.
  • Strengthened the @remarks bullet with the same guidance (shared/public devices are the canonical pain point).
  • Renamed the @example headings so the default is labelled "Sign out of every device (global – default)" with a ⚠️ comment, local is tagged "(recommended for most apps)", and others reads as "keep the current one".

No runtime, type, or API changes — just the JSDoc block above signOut() in packages/core/auth-js/src/GoTrueClient.ts.

Why was this change needed?

Issue #1608 flagged that supabase.auth.signOut() defaults to scope: 'global' — unlike most auth libraries — which signs the user out of every device they're signed in on, including phones/other tabs. The existing JSDoc mentioned the default in passing, but it was easy to miss. Users have spent days debugging why sessions randomly disappear on unrelated devices after a routine sign-out (linked from #1608).

Addresses the first of the three asks in #1608 ("Add a big fat red warning about this"). The error-message rename ("refresh token not found" → "refresh token has been revoked") and the potential behavior change for a major release are out of scope for this docs-only PR and left for separate discussion.

Refs #1608

📸 Screenshots/Examples

Before (existing JSDoc, paraphrased):

By default, signOut() uses the global scope, which signs out all other sessions that the user is logged into as well.

After — the warning is hoisted above @remarks, flagged with ⚠️, and the @example block labels each scope with its real-world use:

@example Sign out of every device (global  default)
// ⚠️ Also signs the user out of every other device / browser they're on.
await supabase.auth.signOut()

@example Sign out only the current session (recommended for most apps)
await supabase.auth.signOut({ scope: 'local' })

@example Sign out of all other sessions, keep the current one
await supabase.auth.signOut({ scope: 'others' })

🔄 Breaking changes

  • This PR contains no breaking changes

📋 Checklist

  • I have read the Contributing Guidelines
  • My PR title follows the conventional commit format: docs(auth): surface global-scope warning on signOut JSDoc
  • I have run prettier --check on the changed file (clean)
  • No tests needed — JSDoc-only change, no runtime/type surface altered
  • Documentation updated (this is the doc update)

📝 Additional notes

Scoped intentionally narrow: the same warning probably belongs on the hosted guide at https://supabase.com/docs/guides/auth/signout and on gotrue-js equivalents. Happy to open follow-ups in those repos if this direction looks right.

Issue supabase#1608 flagged that supabase.auth.signOut() defaults to scope:
'global', which signs the user out of every device they're signed in
on — unlike most auth libraries. The existing JSDoc did mention the
default in passing, but it was easy to miss and users have spent days
debugging why sessions keep disappearing on other devices after a
routine sign-out (linked in supabase#1608).

Rework the JSDoc so the default scope is impossible to miss:

- Add a warning callout directly under the one-liner description,
  noting that 'global' signs out every device and pointing at
  { scope: 'local' } as the common choice.
- Strengthen the @remarks bullet with the same guidance (shared /
  public devices are the canonical pain point).
- Rename the @example headings so the default case is labelled
  'Sign out of every device (global – default)' with a ⚠️ comment,
  'local' is tagged '(recommended for most apps)', and 'others'
  reads as 'keep the current one'.

Docs-only. Behavior and types unchanged, no breaking changes. Addresses
the first of the three asks in supabase#1608 (prominent warning). The error-
message rename and potential behavior change in a major release are
left for a separate discussion.
@MukundaKatta MukundaKatta requested review from a team as code owners April 22, 2026 14:54
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 27, 2026

Open in StackBlitz

@supabase/auth-js

npm i https://pkg.pr.new/@supabase/auth-js@2269

@supabase/functions-js

npm i https://pkg.pr.new/@supabase/functions-js@2269

@supabase/postgrest-js

npm i https://pkg.pr.new/@supabase/postgrest-js@2269

@supabase/realtime-js

npm i https://pkg.pr.new/@supabase/realtime-js@2269

@supabase/storage-js

npm i https://pkg.pr.new/@supabase/storage-js@2269

@supabase/supabase-js

npm i https://pkg.pr.new/@supabase/supabase-js@2269

commit: 5b99a05

Copy link
Copy Markdown
Contributor

@mandarini mandarini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MukundaKatta, thank you so much for contributing to Supabase! 💚 This is a really useful change.

Two small things before I can merge:

  1. Could we tweak the "shared or public devices" framing? On first read it sounds like the opposite advice (one might assume aggressive global logout is for kiosks). The intent is "don't accidentally terminate the user's session on their phone when they sign out of a kiosk", but the sentence makes the reader work for it. Something like:
   > Pass `{ scope: 'local' }` to only sign out the current session. This is usually what apps want on a "Sign out" button, especially when users sign in from multiple devices and do not expect signing out of one to terminate the others.
  1. Could we drop the warning emojis from the JSDoc? We try to keep the public API docs emoji-free across the SDK, so a plain **Warning:** (or **Note:**) prefix would fit our style better. The bold + clear wording will still make the warning stand out in IDE tooltips.

Everything else looks great. The follow-up on the hosted docs page would be very welcome too, separately.

Comment thread packages/core/auth-js/src/GoTrueClient.ts Outdated
Comment thread packages/core/auth-js/src/GoTrueClient.ts Outdated
Comment thread packages/core/auth-js/src/GoTrueClient.ts Outdated
@MukundaKatta
Copy link
Copy Markdown
Contributor Author

Thanks @mandarini, both addressed in 5b99a05.

  • Dropped the ⚠️ emojis and the // ⚠️ line in the example.
  • Reworded the scope guidance to your suggestion (multiple-devices framing).
  • Removed the issues/1608 link from the warning paragraph since the new wording stands on its own.

Will follow up separately on the hosted-docs page.

@mandarini mandarini merged commit 8ccd183 into supabase:develop Apr 28, 2026
22 of 23 checks passed
@mandarini mandarini added patchback-master Patchback commit into master branch. and removed patchback-master Patchback commit into master branch. labels Apr 28, 2026
mandarini added a commit that referenced this pull request Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patchback-master Patchback commit into master branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants