Skip to content

fix(auth): speed up sign-out and show pending state on logout#378

Merged
huv1k merged 9 commits into
mainfrom
huv1k/fix-slow-logout-redirect
Jun 10, 2026
Merged

fix(auth): speed up sign-out and show pending state on logout#378
huv1k merged 9 commits into
mainfrom
huv1k/fix-slow-logout-redirect

Conversation

@huv1k

@huv1k huv1k commented Jun 10, 2026

Copy link
Copy Markdown
Member

Why

Clicking "Log out" appeared to do nothing for several seconds: server actions POST to the current page URL, so the browser sat waiting on a request to e.g. /dashboard/<team>/sandboxes/monitoring?... while completeOrySignOut ran 4 sequential network round-trips (Auth.js sign-out, Hydra consent + login revocation, Kratos session deletion) before returning the redirect — with no pending UI.

What

  • Run the independent Hydra OAuth and Kratos revocations concurrently in completeOrySignOut, and the two Hydra calls (consent + login) concurrently as well — ~3 sequential round-trips collapse to the slowest one; all helpers already log-and-swallow errors and Kratos retries 429 contention.
  • Invoke the sign-out action inside a sync useTransition callback (void signOutAction(), not awaited — the action redirects via NEXT_REDIRECT and awaiting it surfaces noisy aborted-action errors).
  • Close the dropdown on logout click and show a fullscreen "Logging out..." overlay until the redirect lands, portaled to document.body so the sidebar's fixed z-20 stacking context can't trap it under the sticky dashboard header (z-50).

@cla-bot cla-bot Bot added the cla-signed label Jun 10, 2026
@vercel

vercel Bot commented Jun 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
web Ready Ready Preview, Comment Jun 10, 2026 12:50pm
web-juliett Error Error Jun 10, 2026 12:50pm

Request Review

@huv1k huv1k marked this pull request as ready for review June 10, 2026 08:05
@huv1k huv1k requested a review from ben-fornefeld as a code owner June 10, 2026 08:05
Copilot AI review requested due to automatic review settings June 10, 2026 08:05
@huv1k huv1k requested a review from drankou as a code owner June 10, 2026 08:05
@huv1k huv1k marked this pull request as draft June 10, 2026 08:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Improves the perceived and actual speed of user sign-out by reducing sequential network round-trips in the Ory sign-out flow and adding a visible pending state to the sidebar “Log out” menu item while the logout action is in progress.

Changes:

  • Parallelize Ory Hydra (OAuth) and Kratos (identity) revocations during sign-out via Promise.all.
  • Parallelize Hydra consent + login session revocations.
  • Add a transition-driven pending UI for the sidebar logout menu item (disabled state + spinner/label).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/features/dashboard/sidebar/menu.tsx Adds pending/disabled UI state for logout and keeps the dropdown open while logout is in progress.
src/core/server/auth/ory/signout-flow.ts Runs Hydra OAuth revocation and Kratos session revocation concurrently to reduce sign-out latency.
src/core/server/auth/ory/oauth-session.ts Runs Hydra consent and login session revocations concurrently to reduce sign-out latency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/features/dashboard/sidebar/menu.tsx
huv1k added 6 commits June 10, 2026 14:28
Server actions POST to the current page URL, so logout silently blocked
on the full Ory sign-out flow with no feedback. Run the independent
Hydra and Kratos revocations concurrently (~3 sequential round-trips
down to the slowest one) and wrap the logout action in useTransition
with a visible "Logging out..." state.
@huv1k huv1k force-pushed the huv1k/fix-slow-logout-redirect branch from ac531d4 to e37639d Compare June 10, 2026 12:28
@huv1k huv1k marked this pull request as ready for review June 10, 2026 12:36

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7b413c3bce

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/features/dashboard/sidebar/menu.tsx Outdated
// not awaited on purpose: the action redirects (throws NEXT_REDIRECT),
// and awaiting it inside the transition surfaces noisy aborted-action
// errors; the transition still tracks the resulting navigation
void signOutAction()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep logout pending until the server action settles

When logout takes more than a moment, this void call makes the transition callback return immediately, so this component’s isLoggingOut can flip back to false before signOutAction() finishes and before the redirect arrives. That defeats the new fullscreen pending overlay and can also re-enable the menu item during the slow sign-out path this change is trying to cover; use an explicit local loggingOut state or have the transition action await/return the server-action promise while handling the redirect noise separately.

Useful? React with 👍 / 👎.

@huv1k huv1k merged commit 8c2249b into main Jun 10, 2026
13 of 14 checks passed
@huv1k huv1k deleted the huv1k/fix-slow-logout-redirect branch June 10, 2026 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants