Skip to content

[glean-vnext] Reuse the DCR client instead of re-registering on setup and abandoned sign-ins - #5

Open
pragati-agrawal-glean wants to merge 1 commit into
pragati/fix-plugin-token-rotation-reauthfrom
pragati/fix-plugin-dcr-client-reuse
Open

[glean-vnext] Reuse the DCR client instead of re-registering on setup and abandoned sign-ins#5
pragati-agrawal-glean wants to merge 1 commit into
pragati/fix-plugin-token-rotation-reauthfrom
pragati/fix-plugin-dcr-client-reuse

Conversation

@pragati-agrawal-glean

Copy link
Copy Markdown

Port of gleanwork/glean-plugins-vnext#45, stacked on #4 (the rotation fix — uses its syncTokensFromDisk rails). Full history and evidence on the vnext PR.

Problem

One user accumulated 34 registered "Glean Claude Code Plugin" clients. Server-side, the DCR endpoint never dedupes (no user identity in scope at registration) and a 7-day sweeper deletes never-used clients — turning abandoned registrations into later invalid_client failures. Client-side, the plugin discarded its registration far too eagerly; log correlation showed a fresh client_id 6–9s after every setup.configured/setup.reset.

Fixes

  1. setup({email}/{server_url}) only clears credentials when the resolved URL actually changed — re-running setup against the same instance (the dominant trigger, fed by the [SETUP_REQUIRED] → agent-calls-setup loop) no longer burns the registration.
  2. Abandoned sign-ins keep the registration and retry it (abandonPendingSignIn budget); a fresh DCR happens only after two consecutive failures with the same client — the signature of a client actually rejected server-side.
  3. clientInformation() syncs from the shared store so concurrently-starting sessions don't both register.
  4. Registrations are logged ([auth] Registered OAuth client: <id>) — previously invisible.

Verification

🤖 Generated with Claude Code

… and abandoned sign-ins

Port of gleanwork/glean-plugins-vnext#45 (stacked on the rotation fix).

One user accumulated 34 registered clients: the server's DCR endpoint
never dedupes and a 7-day sweeper reaps never-used clients (turning them
into later invalid_client failures), while the plugin discarded its
registration far too eagerly. Fixes:

- setup({email}/{server_url}) only clears credentials when the resolved
  URL actually changed — re-running setup with the same instance was the
  dominant trigger (one new client per call).
- Abandoned sign-ins keep the registration and retry it
  (abandonPendingSignIn budget); full re-registration only after two
  consecutive failures with the same client.
- clientInformation() syncs from the shared store so concurrently
  starting sessions don't both register.
- Registrations are logged ([auth] Registered OAuth client).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@pragati-agrawal-glean
pragati-agrawal-glean force-pushed the pragati/fix-plugin-dcr-client-reuse branch from 1cdaba8 to 59ece6f Compare July 30, 2026 10:50
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.

1 participant