Skip to content

Retry current user request after failure - #8898

Merged
Alex Ross (alexr00) merged 2 commits into
mainfrom
chrmarti/retry-current-user-request
Aug 27, 2026
Merged

Retry current user request after failure#8898
Alex Ross (alexr00) merged 2 commits into
mainfrom
chrmarti/retry-current-user-request

Conversation

@chrmarti

Copy link
Copy Markdown
Contributor

Summary

Retry the authenticated GitHub user request after a transient failure instead of retaining and replaying its rejected promise for the lifetime of the authentication hub.

Session Context

Key decisions from the development session:

  • Fix the retained rejection at its source: A connection timeout during extension activation rejected github.currentUser. Because that promise stayed cached, later PR refreshes failed immediately with the original timeout even after other GitHub requests recovered.
  • Retry on demand: Failed currentUser and isEmu promises are cleared together. The next consumer creates one new shared request, preserving request deduplication without adding an automatic retry loop.
  • Keep recovery consistent: Callers that directly read the cached promise now use the credential-store/repository API so they also trigger retry behavior.
  • Keep progress cleanup separate: This root-cause fix is independent from Fix stuck changes-since-review progress #8897, which ensures the Changes in Pull Request progress indicator settles after refresh failures.

Changes

  • Clear the cached current-user and EMU promises when their shared request fails.
  • Recreate the shared request on the next getCurrentUser, getIsEmu, or isCurrentUser call.
  • Route metadata and contact-provider lookups through the retry-aware API.
  • Add regression coverage for a failed request followed by a successful retry.

Evidence

The log showed only one current-user request during activation:

2026-08-24 11:24:52.079 [debug] [Authentication] Getting current user
2026-08-24 11:24:52.079 [error] [Authentication] Failed to get current user: HttpError: Connect Timeout Error (attempted address: api.github.com:443, timeout: 10000ms)

Hours later, PR initialization replayed that same failure within milliseconds while other GitHub requests succeeded:

2026-08-25 08:37:09.747 [debug] [PullRequestModel] Fetch file changes, base, head and merge base of PR #332245 - enter
2026-08-25 08:37:09.752 [error] [Review+0] Failed to initialize PR data HttpError: Connect Timeout Error (attempted address: api.github.com:443, timeout: 10000ms)
2026-08-25 08:37:10.895 [debug] [GitHubRepository+0] Fetch pull request 332245 - done

GitHub Pull Request log showing the api.github.com timeout

Validation

  • npm test - 478 passing
  • npm run lint
  • npm run hygiene
  • git diff --check

Clear failed current-user and EMU promise caches so later GitHub operations can retry instead of replaying an activation-time network error.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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

This PR fixes a reliability issue in the authentication hub where a failed currentUser request could be cached as a rejected promise and then immediately replayed for the rest of the session. The change clears the cached currentUser/isEmu promises when their shared request fails, so the next consumer triggers a fresh (deduplicated) request instead of reusing the stale failure.

Changes:

  • Clear cached currentUser and isEmu promises when the underlying shared request rejects, enabling on-demand retry.
  • Route current-user lookups through GitHubRepository.getAuthenticatedUser() so callers benefit from the retry behavior.
  • Add a regression test covering “failure then successful retry” while preserving request deduplication.
Show a summary per file
File Description
src/github/credentials.ts Implements retry-on-demand by clearing cached rejected promises and re-initializing shared currentUser/isEmu requests.
src/github/githubRepository.ts Uses getAuthenticatedUser() when composing repo metadata to avoid reading a potentially stale cached promise directly.
src/gitProviders/GitHubContactServiceProvider.ts Uses origin.getAuthenticatedUser() so contact-provider login lookup triggers retry behavior when needed.
src/test/github/credentials.test.ts Adds a regression test ensuring the current-user request is retried after a transient failure and remains deduplicated.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Lite

@alexr00
Alex Ross (alexr00) marked this pull request as ready for review August 27, 2026 09:54
Copilot AI review requested due to automatic review settings August 27, 2026 09:54
@alexr00
Alex Ross (alexr00) enabled auto-merge (squash) August 27, 2026 09:54

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.

Review details

  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

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.

4 participants