fix(referral): propagate reward completion errors to allow Stripe retry#28723
Open
PanAchy wants to merge 1 commit into
Open
fix(referral): propagate reward completion errors to allow Stripe retry#28723PanAchy wants to merge 1 commit into
PanAchy wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #28722
Type of change
What does this PR do?
Problem 1 — Silently swallowed errors:
The
customer.subscription.createdwebhook calledReferral.completeFromLiteSubscription(...)with.catch(console.error), swallowing any error and always returning 200 to Stripe. This means transient failures (DB errors, race conditions) never trigger Stripe's retry mechanism, permanently leaving the referral reward inpending.Problem 2 — Spurious throws for non-referred subscribers:
completeFromLiteSubscriptionpreviously threw"Referral not found"when a subscriber had no referral row (i.e., the vast majority of subscribers). This meant every non-referred subscription was generating a swallowed error — noisy and masking real failures.Fix:
webhook.ts: Remove.catch(console.error). Let real errors propagate so Stripe retries on failure.referral.ts: ChangecompleteFromLiteSubscriptionto return early (no-op) when no referral row exists for the invitee account. Non-referred subscribers now produce no error.How did you verify your code works?
bun test test/referral.test.tsinpackages/console/core— 1 pass, 0 fail.bun typecheckinpackages/console/coreandpackages/console/app— no errors.Screenshots / recordings
If this is a UI change, please include a screenshot or recording.
Checklist
If you do not follow this template your PR will be automatically rejected.