Skip to content

fix: clear stale client registration on re-login after token expiry - #4

Merged
nathanBurg merged 1 commit into
mainfrom
nathanBurg/fix-expired-login
Mar 28, 2026
Merged

fix: clear stale client registration on re-login after token expiry#4
nathanBurg merged 1 commit into
mainfrom
nathanBurg/fix-expired-login

Conversation

@nathanBurg

@nathanBurg nathanBurg commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Users and AI agents (Claude Code, Gemini CLI) experience a "cannot read properties of id" crash when running githits login after their session expires. The only workaround is to run githits logout first, which is poor UX — especially for automated workflows.

The root cause: when tokens expire and refresh fails, TokenManager clears the tokens but leaves the DCR client registration behind. The next login call sees no tokens, skips the expired-token path, but reuses the stale client registration — which the server has already invalidated.

This fix clears the client registration when no tokens exist (so a fresh DCR happens) and does best-effort cleanup on token exchange failure. It also adds 5 new tests and fixes pre-existing lint warnings across test files.

Test plan

  • bun run typecheck passes
  • bun run format:check passes
  • bun run lint passes (0 warnings)
  • bun run build succeeds
  • bun test — 249 tests pass
  • Manual: login, wait for token expiry, login again without running logout first

🤖 Generated with Claude Code

When tokens expire and refresh fails, TokenManager clears tokens but
leaves the DCR client registration. Subsequent login attempts reuse the
stale client, causing a crash. Now login clears the client when no
tokens exist, and does best-effort cleanup on token exchange failure.

Also fixes pre-existing lint warnings (unused imports, non-null
assertions in test files) and disables noNonNullAssertion for tests
in biome config.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nathanBurg nathanBurg self-assigned this Mar 25, 2026

@nathanBurg nathanBurg left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jlitola I need to give it about a day to actually test this and make sure the fix works.

@nathanBurg
nathanBurg merged commit a8c476c into main Mar 28, 2026
5 checks passed
nathanBurg added a commit that referenced this pull request Mar 28, 2026
Publishes the expired-login fix (PR #4) to npm.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nathanBurg nathanBurg mentioned this pull request Mar 28, 2026
2 tasks
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.

2 participants