You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
generateUniqueUsername issues one query per candidate and can make 101 round trips for a single sign-in #790
One SELECT per iteration, up to 101 of them, on the OAuth sign-in path.
Why it matters: it is also racy in a way the loop cannot fix — two concurrent sign-ins for the same colliding login both settle on login-1, and the second insert violates the unique constraint, which nothing catches. So the loop pays up to 101 queries for a result that is still not guaranteed.
upsertFromGithub performs several other sequential existence checks for the same reason (:67-69, :88-90, :109-111, :118-120), so a single sign-in can be a dozen round trips before anything is written.
Fix: let the database decide — insert with the preferred username, catch the unique violation, and retry with a short random suffix. That is one query in the common case, correct under concurrency, and removes the arbitrary 100 cap. The Date.now() escape hatch can go with it.
@Divine639700 has applied to work on this issue as part of the Stellar Wave Program's 11th wave.
Hi maintainer, I’d like to optimize generateUniqueUsername by replacing repeated database lookups with an insert-and-retry approach that handles unique constraint violations safely. I’ll also address the sequential existence checks in upsertFromGithub and add tests covering concurrent sign-ins, username collisions, and retry behaviour
Congratulations, @jd-here-007! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on November 25, 2026.
🧑💻 @jd-here-007: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.
Warning
When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.
🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.
😎 @jd-here-007: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.
🧑💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.
Activity
Divine639700 commentedon Nov 19, 2026
@Divine639700 has applied to work on this issue as part of the Stellar Wave Program's 11th wave.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @Divine639700 to this issue.
jd-here-007 commentedon Nov 19, 2026
@jd-here-007 has applied to work on this issue as part of the Stellar Wave Program's 11th wave.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @jd-here-007 to this issue.
drips-wave commentedon Nov 19, 2026
Congratulations, @jd-here-007! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on November 25, 2026.
🧑💻 @jd-here-007: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.
Warning
When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.
🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.
🌊 Happy Wave 🌊
drips-wave commentedon Nov 20, 2026
This issue has been completed by @jd-here-007 as part of the Stellar Wave Program's 11th Wave 🥳
😎 @jd-here-007: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.
🧑💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.