fix(billing): recover org stripe bootstrap when reload misses - #3361
posthog-eu[bot] wants to merge 1 commit into
Conversation
createStripeCustomer re-selected the org row and threw when the row was not yet visible, which aborted the whole billing bootstrap for a new org: no Stripe customer, no stripe_info trial row, no trial plan. The only caller already reloads that row and falls back to the INSERT queue payload, so the re-select made that fallback dead code. - Make the reload guard return null instead of throwing, and reuse the org row the caller passed when the reload misses. - Carry the org id and the underlying Supabase error in the race-recovery exception message so error tracking can tell which org failed. Generated-By: PostHog Desktop Task-Id: 90002b6d-354d-4379-a704-5c0244fffa28
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merging this PR will not alter performance
Comparing Footnotes
|
|



Summary
stripe_infotrial row, and no trial plan.createStripeCustomerre-selected the org row and threwcreateStripeCustomer org reload failedwhen the committed row was not yet visible, which aborted the whole billing bootstrap for that org.on_organization_create) already reloads that row and deliberately falls back to the INSERT queue payload, so the helper's re-select made that fallback dead code — it re-ran the same query and threw anyway.nullinstead of throwing, andcreateStripeCustomerreuses the org row the caller passed when the reload misses. A stale read no longer aborts provisioning.Test plan
bun test:unit— updatedtests/stripe-org-customer.unit.test.ts: the reload-miss case now asserts recovery (customer created, plan returned, link uses the passed row) instead of a throw.bun run typecheck:backendandbun run lint:backendpass.Screenshots
Checklist
bun run lint:backend && bun run lint.accordingly.
my tests
Created with PostHog Desktop from this inbox report.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.