Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defer GitHub API creation to PR handlers #246

Merged
merged 2 commits into from
Apr 28, 2019

Conversation

bobvanderlinden
Copy link
Owner

@bobvanderlinden bobvanderlinden commented Apr 28, 2019

Whenever a GitHub API is created, tokens are checked and refreshed. Because GitHub tokens were being used across multiple jobs in a repository-queue, it could happen that the tokens were expired once a job later in the queue was started.

This change makes sure the GitHub API is created when a job is going to be processed. That way the tokens are checked at the beginning of each jobs, instead of at the beginning of the job queue.

It does this by running app.auth(installationId, log) each time a job is started in RepositoryWorker. installationId and app are hidden for RepositoryWorker{s,} by wrapping the app.auth call inside createGitHubAPI.

Whenever a GitHub context is created, tokens are checked and refreshed.
Because GitHub tokens were being used across multiple jobs in a
repository-queue, it could happen that the tokens were expired once a
job later in the queue was started.

This change makes sure the GitHub API is created when the jobs is going
to be processed. That way the tokens are checked at the beginning of
each jobs, instead of at the beginning of the job queue.
@bobvanderlinden bobvanderlinden changed the title Defer github API creation to PR handlers Defer GitHub API creation to PR handlers Apr 28, 2019
@bobvanderlinden bobvanderlinden merged commit 6b53687 into master Apr 28, 2019
@bobvanderlinden bobvanderlinden deleted the pr-fix-github-tokens branch April 28, 2019 20:17
@bobvanderlinden
Copy link
Owner Author

🎉 This PR is included in version 1.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant