Repository navigation
Conversation
…deleted subscription Adds a race test (npm run test:race, in npm test) that runs the webhook writes in every order. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
@ohad6k is attempting to deploy a commit to the BoxyHQ Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
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.
Stripe doesn't guarantee webhook order. In
handleSubscriptionUpdated, when no subscription row is found but the team exists, the handler callshandleSubscriptionCreated. Ifcustomer.subscription.deletedis processed before an oldercustomer.subscription.updated, theupdatedhandler finds no row and recreates the cancelled subscription withactive: true.Fix: in the missing-row branch, re-read the subscription from Stripe (
stripe.subscriptions.retrieve) and return when its status iscanceledorincomplete_expired. Otherwise the row is created as before.Test:
npm run test:raceruns the two deliveries in every order on a real Postgres. 0/56 orders broken with the fix, 4/56 without the Stripe check (the spec models the Stripe re-read as astripe_truthtable). It usesviberaven race(open source). The race test now runs innpm test(jest && npm run test:race), so future webhook changes stay covered. The existing jest suite also passes (4/4).Limits: the Stripe call is modelled, not executed. The update branch still writes the event payload as-is, so an older
updatedafter a newer one can overwrite price or dates; not changed here.npm testnow needs network access fornpx.