-
I am cloning a repository that my app has access to. In order to do this, I am first generating a token like so, using the octokit instance provided by probot: const tokenResponse: { token: string } = (await context.octokit.auth({ type: 'installation' })) as { token: string }; Then, I clone the repo by launching a command similar to the following git clone https://x-access-token:${tokenResponse.token}@github.com/${owner}/${repo} /tmp/target-temp-directory This works 99.9% of the time. However, once in a while, I will get a failure with this output from the git command:
When I say it works 99.9% of the time, I mean with the same repository that it it will occassionally fail with. I read on the GitHub docs that tokens last an hour, but I'm generating the token immediately before attempting the clone with no room for delay in between. Does Probot and/or Octokit somehow cache the token and reuse it? I was thinking of adding a retry loop, but I feel like I need more context on what's happening before attempting a blind fix. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
there might be a delay until a newly installation access token propagates to all read-only follower databases. For requests we take this into account and will do request retries for you: But as you take the token out of octokit's control, you might run into a situation where an authentication fails because whatever instance is receiving your git requests does not yet have the installation access token. I'd recommend to either make a poor-person's 5 second delay before you do the git command, or you implement a retry similar to what we do in the app authentication strategy implementation |
Beta Was this translation helpful? Give feedback.
there might be a delay until a newly installation access token propagates to all read-only follower databases. For requests we take this into account and will do request retries for you:
https://github.com/octokit/auth-app.js/blob/d5bcdfc6a76a022a9bc82bcc974e4d33dfe3c9a4/src/hook.ts#L108-L114
But as you take the token out of octokit's control, you might run into a situation where an authentication fails because whatever instance is receiving your git requests does not yet have the installation access token.
I'd recommend to either make a poor-person's 5 second delay before you…