Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

github apps: sleep before redirecting to installations/new#53064

Merged
courier-new merged 1 commit into
batches/commit-signingfrom
kr/sleep-before-redirect
Jun 7, 2023
Merged

github apps: sleep before redirecting to installations/new#53064
courier-new merged 1 commit into
batches/commit-signingfrom
kr/sleep-before-redirect

Conversation

@courier-new

Copy link
Copy Markdown
Contributor

I noticed that every once in a while (~5-10% of the time?), GitHub would 404 after it creates the new app and attempts to redirect to the page to install it. I'd think I did something wrong at first, but I would come back to the page a minute later and it'd be functional again. I think there's just a small race condition between GitHub finishing creating the app on their end and Sourcegraph redirecting to the new app's install page.

This PR just introduces a small delay before the redirect event to try to smooth this out. The sleep delay amount was chosen purely based on empirical evidence. I didn't see the 404s after adding a 3s delay and creating about ~20 new Apps. It's possible an even smaller delay would suffice, given we probably also have lower-than-normal latency when following the workflow from our locally-running instances, but 3s doesn't feel too long to wait.

Test plan

Aggressive manual testing. 😛

@courier-new courier-new requested review from a team, kopancek and pjlast June 7, 2023 07:34
@courier-new courier-new self-assigned this Jun 7, 2023
@cla-bot cla-bot Bot added the cla-signed label Jun 7, 2023
@sourcegraph-bot

Copy link
Copy Markdown
Contributor

Codenotify: Notifying subscribers in CODENOTIFY files for diff c6be395...1d9446d.

Notify File(s)
@unknwon enterprise/cmd/frontend/internal/auth/githubappauth/middleware.go

@sourcegraph-bot

Copy link
Copy Markdown
Contributor

📖 Storybook live preview

@BolajiOlajide BolajiOlajide 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.

Nice catch

@pjlast pjlast 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.

Yeah makes 100% sense, I've run into this issue with other GitHub features as well. Webhooks for example: you can get a webhook trigger that a user has been added to an org, and then if you immediately query the list of users in that org, the user won't show yet.

An alternative is to not have the App install be part of the creation flow, but I think this is a decent mitigation for now.

@courier-new courier-new merged commit d84a5a8 into batches/commit-signing Jun 7, 2023
@courier-new courier-new deleted the kr/sleep-before-redirect branch June 7, 2023 17:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants