Skip to content

[FEAT]: coalesce concurrent authentication calls #688

@jenseng

Description

@jenseng

Describe the need

Context

This is somewhat related to octokit/octokit.js#2800. Although installation access tokens are cached for an hour, this caching only takes effect once a token is acquired. If a token is not yet cached (or is expired), and you trigger authentication multiple times concurrently, then multiple identical requests will be made to /app/installations/.../access_tokens. This is redundant and inefficient, and can negatively impact other API calls, depending on your throttling configuration. This suboptimal behavior was observed in writing tests for octokit/plugin-throttling.js#779.

Proposal

If an authentication request is already in flight (i.e. getInstallationAuthentication has been called but the promise has not yet resolved), subsequent calls with the same options should return the same promise. This way we ensure that we only query and cache the token once.

SDK Version

No response

API Version

No response

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions