Skip to content

Github api token caching: race condition in installation token refresh #528

Closed

Description

@itsmiso-ai

Parent umbrella issue: #495
Source audit: Weekly tech debt audit: dispatch - 2026-07-01
Source audit date: 2026-07-01

Original recommendation

Github api token caching: race condition in installation token refresh

Evidence: src/lib/github.ts lines 47-128 — the GitHub App installation token cache uses module-level mutable state (installationTokenCache). The refreshIfNeeded() and getGitHubToken() functions are not mutex-protected. If two concurrent requests enter refreshIfNeeded() when the cache is near expiry, both could attempt to fetch a new token simultaneously, causing redundant API calls. In the worst case, a race condition during initial ensureInit() could leave useGitHubApp=false after a transient failure, silently falling back to PAT auth.


Matched top finding

Evidence: src/lib/github.ts lines 47-128 — the GitHub App installation token cache uses module-level mutable state (installationTokenCache). The refreshIfNeeded() and getGitHubToken() functions are not mutex-protected. If two concurrent requests enter refreshIfNeeded() when the cache is near expiry, both could attempt to fetch a new token simultaneously, causing redundant API calls. In the worst case, a race condition during initial ensureInit() could leave useGitHubApp=false after a transient failure, silently falling back to PAT auth.


Activity

  1. added
    auditAudit, review, or investigation work.
    status/backlogNot ready for worker pickup yet.
    type/bugSomething isn't working
    status/readyReady for Dispatch worker pickup.
    and removed
    status/backlogNot ready for worker pickup yet.
    on Jul 2, 2026
  2. itsmiso-ai commented on Jul 3, 2026

    @itsmiso-ai
    ContributorAuthor

    This issue has detailed technical context, P1 priority, and clear code evidence. Ready to move from backlog to a claimable lane for implementation.

  3. added a commit that references this issue on Jul 4, 2026
    46725b4
  4. added
    status/readyReady for Dispatch worker pickup.
    and removed on Jul 5, 2026
  5. added a commit that references this issue on Jul 5, 2026
    3c78fb5
  6. added and removed
    status/backlogNot ready for worker pickup yet.
    on Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    auditAudit, review, or investigation work.priority/p1High priority.status/doneWork is complete.type/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions