Skip to content

Fix spacetime logout failing when offline#4361

Merged
bfops merged 1 commit intomasterfrom
bot/logout-offline-fix
Feb 23, 2026
Merged

Fix spacetime logout failing when offline#4361
bfops merged 1 commit intomasterfrom
bot/logout-offline-fix

Conversation

@clockwork-labs-bot
Copy link
Copy Markdown
Collaborator

Fixes #2437

spacetime logout previously required a network connection to the auth server, making it impossible to log out (and thus log in with a different method) when offline.

This change makes the server-side session invalidation best-effort: if the auth server is unreachable, a warning is printed but local credentials are still cleared. This allows offline development workflows like spacetime login --server-issued-login local.

Copy link
Copy Markdown
Collaborator

@bfops bfops left a comment

Choose a reason for hiding this comment

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

This LGTM - waiting for another human to approve

@bfops bfops changed the title Fix spacetime logout failing when offline Fix spacetime logout failing when offline Feb 20, 2026
Copy link
Copy Markdown
Collaborator

@jdetter jdetter left a comment

Choose a reason for hiding this comment

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

Seems fine to me - haven't tested myself but the change makes sense 👍

@bfops bfops added this pull request to the merge queue Feb 23, 2026
Merged via the queue into master with commit 3b48c4b Feb 23, 2026
33 of 34 checks passed
github-merge-queue Bot pushed a commit that referenced this pull request Mar 6, 2026
## Summary

Improves the `spacetime login` and `spacetime logout` UX to behave more
like standard CLI tools.

### `spacetime login`

**Before:** If already logged in, prints "You are already logged in" and
exits. User must manually run `logout` first.

**After:** If already logged in, automatically logs out the previous
session and proceeds with a fresh login. Prints the old identity being
logged out and the new identity on success.

```
$ spacetime login
Logged out of previous session (identity 0xabc...).
Opening https://spacetimedb.com/login/cli?token=... in your browser.
Waiting to hear response from the server...
Logged in with identity 0xdef...
```

### `spacetime logout`

**Before:** No output on success. Hard failure if offline.

**After:**
- Prints confirmation: `Logged out (identity 0xabc...).`
- Prints `You are not logged in.` if already logged out
- Best-effort server-side session invalidation with 5s timeout (prints
warning if offline instead of failing)

### Changes

- `login.rs`: Remove `spacetimedb_token_cached` early-return; instead
log out previous session and proceed. Show identity on login success.
- `logout.rs`: Add identity display, not-logged-in check, 5s timeout for
server call with warning on failure.

Note: This subsumes the offline fix from #4361.

---------

Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
@bfops bfops deleted the bot/logout-offline-fix branch April 14, 2026 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI - spacetime logout fails if offline

3 participants