René's URL Explorer Experiment


Title: fix(billing): serialize Gmail inbox allowance decisions so racing alias signups can't both keep it by waleedlatif1 · Pull Request #9431 · simstudioai/sim · GitHub

Open Graph Title: fix(billing): serialize Gmail inbox allowance decisions so racing alias signups can't both keep it by waleedlatif1 · Pull Request #9431 · simstudioai/sim

X Title: fix(billing): serialize Gmail inbox allowance decisions so racing alias signups can't both keep it by waleedlatif1 · Pull Request #9431 · simstudioai/sim

Description: Summary Better Auth commits each user row before user.create.after runs, so two signups on one Gmail inbox could race: the later account's earlier-account check could run before the earlier row was visible, and both kept the free allowance (follow-up to #9418) handleNewUser now decides inside one transaction under a per-inbox advisory lock (acquireGmailInboxLock, existing acquireAdvisoryXactLock), inserts the stats row, then withdraws the allowance from any later alias on the inbox that got in first (laterGmailAliasesWithAllowance) — the earliest account keeps it whichever hook runs first The stats-row fallback keeps an unlocked check: it only runs when a signup's own decision failed, and locking there would hold the inbox lock through the caller's transaction; it never withdraws from later accounts, so long-standing aliases are never stripped retroactively identityHadFreeAllowance moves to lib/users/free-allowance.ts; the admin balance grant now uses it, so a stats row it creates applies the Gmail rule too (it previously checked deleted identities only) Alias lookups are a single self-join on user_gmail_mailbox_idx; test schema mock gains gmailMailbox Type of Change Bug fix Testing lib/users/gmail-alias.integration.ts on real Postgres (INTEGRATION_DB_PROVISION=migrate): 11/11. New guards shown red with the fix disabled: an alias whose signup decided first loses the allowance once the earlier account decides; a held inbox lock blocks a same-inbox signup (pg_blocking_pids); the fallback never withdraws from a later alias. Index test now EXPLAINs the self-join shape lib/billing/core/usage.test.ts, lib/admin/dashboard-credit-grant.test.ts: 30/30 bun run lint, check:file-names, check:test-patterns, check:comment-hygiene, check:unused-exports, check:boundaries, check:schema-mock; drizzle-kit generate reports no drift Full type-check / audits / suites left to CI Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing (new tests pass the test-audit authoring gate) No new warnings introduced I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Open Graph Description: Summary Better Auth commits each user row before user.create.after runs, so two signups on one Gmail inbox could race: the later account's earlier-account check could run before the earlier ro...

X Description: Summary Better Auth commits each user row before user.create.after runs, so two signups on one Gmail inbox could race: the later account's earlier-account check could run before the earlie...

Opengraph URL: https://github.com/simstudioai/sim/pull/9431

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:16bac4a6-3f78-76a0-4c4d-b6f07337ebe4
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idC0E0:88B0B:B084A:FCDC4:6AFB1C3F
html-safe-nonce25f3b6a6d4abcc460f91a2517c07e859a402ffbb0df34b8ca32fc0cc8a7cfda9
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMEUwOjg4QjBCOkIwODRBOkZDREM0OjZBRkIxQzNGIiwidmlzaXRvcl9pZCI6IjMxMTczMDM5NjgzNTk0NTU4MDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac01ea1dbc63460744fbf91c716ed412a69a3891595b3fb7b231e5268ab79ab815
hovercard-subject-tagpull_request:5060347771
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/9431/files
twitter:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
og:image:altSummary Better Auth commits each user row before user.create.after runs, so two signups on one Gmail inbox could race: the later account's earlier-account check could run before the earlier ro...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None24933791aba0f10b2f189f8b953a1452dd79933933ac13a0a67b8ad3acee3d9f
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/simstudioai/sim git https://github.com/simstudioai/sim.git
octolytics-dimension-user_id199344406
octolytics-dimension-user_loginsimstudioai
octolytics-dimension-repository_id912559512
octolytics-dimension-repository_nwosimstudioai/sim
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id912559512
octolytics-dimension-repository_network_root_nwosimstudioai/sim
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release030711cc180b563614a434f4376acf7da5d445fa
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/simstudioai/sim/pull/9431/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F9431%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F9431%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=simstudioai%2Fsim
Reloadhttps://github.com/simstudioai/sim/pull/9431/files
Reloadhttps://github.com/simstudioai/sim/pull/9431/files
Reloadhttps://github.com/simstudioai/sim/pull/9431/files
simstudioaihttps://github.com/simstudioai
simhttps://github.com/simstudioai/sim
Codehttps://github.com/simstudioai/sim
Issues129 (129)https://github.com/simstudioai/sim/issues
Pull requests198 (198)https://github.com/simstudioai/sim/pulls
Actionshttps://github.com/simstudioai/sim/actions
Projectshttps://github.com/simstudioai/sim/projects
Security and qualityhttps://github.com/simstudioai/sim/security
Insightshttps://github.com/simstudioai/sim/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
waleedlatif1https://github.com/waleedlatif1
staginghttps://github.com/simstudioai/sim/tree/staging
fix/gmail-inbox-allowance-racehttps://github.com/simstudioai/sim/tree/fix/gmail-inbox-allowance-race
Conversation 10 https://github.com/simstudioai/sim/pull/9431
Commits 2 https://github.com/simstudioai/sim/pull/9431/commits
Checks 67 https://github.com/simstudioai/sim/pull/9431/checks
Files changed https://github.com/simstudioai/sim/pull/9431/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/9431/files
fix(billing): serialize Gmail inbox allowance decisions so racing alias signups can't both keep it https://github.com/simstudioai/sim/pull/9431/files#top
Show all changes 2 commits https://github.com/simstudioai/sim/pull/9431/files
cc956c1 fix(billing): serialize Gmail inbox allowance decisions so racing ali… waleedlatif1 Oct 29, 2026 https://github.com/simstudioai/sim/pull/9431/commits/cc956c153072623a7f6693ef19a0fc27d1a1bc43
14b5fb2 fix(billing): restore lock_timeout after taking the Gmail inbox lock waleedlatif1 Oct 29, 2026 https://github.com/simstudioai/sim/pull/9431/commits/14b5fb2c73c21abe709e5bac15d20c8c6850fc30
Clear filters https://github.com/simstudioai/sim/pull/9431/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/9431/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/9431/files
dashboard-credit-grant.test.ts https://github.com/simstudioai/sim/pull/9431/files#diff-7d242deb03a78b7d52decab2cfb288f1ac28714f477738ced13bd401103a1f2e
dashboard.ts https://github.com/simstudioai/sim/pull/9431/files#diff-5c387d1340d6c2018ddbd5f5b624f978ebc0ac158ea97ef66de7dfc9586d07dc
usage.test.ts https://github.com/simstudioai/sim/pull/9431/files#diff-76cbcb288fc18e02a54367b5d926740e68df335b2b118c1d92cb407704fba1fd
usage.ts https://github.com/simstudioai/sim/pull/9431/files#diff-41305ed8be4067cf242cf6c6f01c4c2aa537836b1072141acf9adaef0e2a40e8
free-allowance.ts https://github.com/simstudioai/sim/pull/9431/files#diff-9cbb76088c2ec7af9c1b1f55b213b2c3cbeca5b6b0c27f83b7d4bd0acca974dc
gmail-alias.integration.ts https://github.com/simstudioai/sim/pull/9431/files#diff-ff76b6cfbf5c9c489a68fe9b1081be218e2b12dbd585db9a7bff9df6128fa255
gmail-alias.ts https://github.com/simstudioai/sim/pull/9431/files#diff-5134a58049c24668add29766a5763c2be8b46bcc07541adcf15faae62773b60f
schema.mock.ts https://github.com/simstudioai/sim/pull/9431/files#diff-3b648ee44a059e5fc069169fdfd7c32c89200a3e79b5d0dc25227d3470da73af
apps/sim/lib/admin/dashboard-credit-grant.test.tshttps://github.com/simstudioai/sim/pull/9431/files#diff-7d242deb03a78b7d52decab2cfb288f1ac28714f477738ced13bd401103a1f2e
View file https://github.com/simstudioai/sim/blob/14b5fb2c73c21abe709e5bac15d20c8c6850fc30/apps/sim/lib/admin/dashboard-credit-grant.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/9431/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/9431/files#diff-7d242deb03a78b7d52decab2cfb288f1ac28714f477738ced13bd401103a1f2e
https://github.com/simstudioai/sim/pull/9431/files#diff-7d242deb03a78b7d52decab2cfb288f1ac28714f477738ced13bd401103a1f2e
https://github.com/simstudioai/sim/pull/9431/files#diff-7d242deb03a78b7d52decab2cfb288f1ac28714f477738ced13bd401103a1f2e
https://github.com/simstudioai/sim/pull/9431/files#diff-7d242deb03a78b7d52decab2cfb288f1ac28714f477738ced13bd401103a1f2e
https://github.com/simstudioai/sim/pull/9431/files#diff-7d242deb03a78b7d52decab2cfb288f1ac28714f477738ced13bd401103a1f2e
https://github.com/simstudioai/sim/pull/9431/files#diff-7d242deb03a78b7d52decab2cfb288f1ac28714f477738ced13bd401103a1f2e
apps/sim/lib/admin/dashboard.tshttps://github.com/simstudioai/sim/pull/9431/files#diff-5c387d1340d6c2018ddbd5f5b624f978ebc0ac158ea97ef66de7dfc9586d07dc
View file https://github.com/simstudioai/sim/blob/14b5fb2c73c21abe709e5bac15d20c8c6850fc30/apps/sim/lib/admin/dashboard.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/9431/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/9431/files#diff-5c387d1340d6c2018ddbd5f5b624f978ebc0ac158ea97ef66de7dfc9586d07dc
https://github.com/simstudioai/sim/pull/9431/files#diff-5c387d1340d6c2018ddbd5f5b624f978ebc0ac158ea97ef66de7dfc9586d07dc
https://github.com/simstudioai/sim/pull/9431/files#diff-5c387d1340d6c2018ddbd5f5b624f978ebc0ac158ea97ef66de7dfc9586d07dc
https://github.com/simstudioai/sim/pull/9431/files#diff-5c387d1340d6c2018ddbd5f5b624f978ebc0ac158ea97ef66de7dfc9586d07dc
apps/sim/lib/billing/core/usage.test.tshttps://github.com/simstudioai/sim/pull/9431/files#diff-76cbcb288fc18e02a54367b5d926740e68df335b2b118c1d92cb407704fba1fd
View file https://github.com/simstudioai/sim/blob/14b5fb2c73c21abe709e5bac15d20c8c6850fc30/apps/sim/lib/billing/core/usage.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/9431/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/9431/files#diff-76cbcb288fc18e02a54367b5d926740e68df335b2b118c1d92cb407704fba1fd
https://github.com/simstudioai/sim/pull/9431/files#diff-76cbcb288fc18e02a54367b5d926740e68df335b2b118c1d92cb407704fba1fd
apps/sim/lib/billing/core/usage.tshttps://github.com/simstudioai/sim/pull/9431/files#diff-41305ed8be4067cf242cf6c6f01c4c2aa537836b1072141acf9adaef0e2a40e8
View file https://github.com/simstudioai/sim/blob/14b5fb2c73c21abe709e5bac15d20c8c6850fc30/apps/sim/lib/billing/core/usage.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/9431/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/9431/files#diff-41305ed8be4067cf242cf6c6f01c4c2aa537836b1072141acf9adaef0e2a40e8
https://github.com/simstudioai/sim/pull/9431/files#diff-41305ed8be4067cf242cf6c6f01c4c2aa537836b1072141acf9adaef0e2a40e8
https://github.com/simstudioai/sim/pull/9431/files#diff-41305ed8be4067cf242cf6c6f01c4c2aa537836b1072141acf9adaef0e2a40e8
https://github.com/simstudioai/sim/pull/9431/files#diff-41305ed8be4067cf242cf6c6f01c4c2aa537836b1072141acf9adaef0e2a40e8
https://github.com/simstudioai/sim/pull/9431/files#diff-41305ed8be4067cf242cf6c6f01c4c2aa537836b1072141acf9adaef0e2a40e8
https://github.com/simstudioai/sim/pull/9431/files#diff-41305ed8be4067cf242cf6c6f01c4c2aa537836b1072141acf9adaef0e2a40e8
https://github.com/simstudioai/sim/pull/9431/files#diff-41305ed8be4067cf242cf6c6f01c4c2aa537836b1072141acf9adaef0e2a40e8
apps/sim/lib/users/free-allowance.tshttps://github.com/simstudioai/sim/pull/9431/files#diff-9cbb76088c2ec7af9c1b1f55b213b2c3cbeca5b6b0c27f83b7d4bd0acca974dc
View file https://github.com/simstudioai/sim/blob/14b5fb2c73c21abe709e5bac15d20c8c6850fc30/apps/sim/lib/users/free-allowance.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/9431/{{ revealButtonHref }}
apps/sim/lib/users/gmail-alias.integration.tshttps://github.com/simstudioai/sim/pull/9431/files#diff-ff76b6cfbf5c9c489a68fe9b1081be218e2b12dbd585db9a7bff9df6128fa255
View file https://github.com/simstudioai/sim/blob/14b5fb2c73c21abe709e5bac15d20c8c6850fc30/apps/sim/lib/users/gmail-alias.integration.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/9431/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/9431/files#diff-ff76b6cfbf5c9c489a68fe9b1081be218e2b12dbd585db9a7bff9df6128fa255
https://github.com/simstudioai/sim/pull/9431/files#diff-ff76b6cfbf5c9c489a68fe9b1081be218e2b12dbd585db9a7bff9df6128fa255
https://github.com/simstudioai/sim/pull/9431/files#diff-ff76b6cfbf5c9c489a68fe9b1081be218e2b12dbd585db9a7bff9df6128fa255
https://github.com/simstudioai/sim/pull/9431/files#diff-ff76b6cfbf5c9c489a68fe9b1081be218e2b12dbd585db9a7bff9df6128fa255
https://github.com/simstudioai/sim/pull/9431/files#diff-ff76b6cfbf5c9c489a68fe9b1081be218e2b12dbd585db9a7bff9df6128fa255
https://github.com/simstudioai/sim/pull/9431/files#diff-ff76b6cfbf5c9c489a68fe9b1081be218e2b12dbd585db9a7bff9df6128fa255
Please reload this pagehttps://github.com/simstudioai/sim/pull/9431/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/9431/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.