Bug report
Describe the bug
Switching from a subscription in trial to another subscription, results in the subscription in trial still persisting in the database as the active subscription after webhook events are handled.
To Reproduce
- Create a subscription to product with trial.
- While in trial update to another subscription.
- Note that the following webhook events trigger:
customer.subscription.trial_will_end
customer.subscription.updated
...
- The webhook handler updates the subscription from the
trial_will_end event.
- The webhook ignores the subscription from
updated event because it has the exact same timestamp as trial_will_end event
Expected behavior
Subscription from customer.subscription.updated event should be the last one to be persisted in database, not trial_will_end
Additional context
Changing this comparison to <= seems to resolve this issue:
https://github.com/supabase/stripe-sync-engine/blob/10955c71fdfb52be84c977ef8ca6b6841c6f0ba3/packages/sync-engine/src/database/postgres.ts#L203
Bug report
Describe the bug
Switching from a subscription in trial to another subscription, results in the subscription in trial still persisting in the database as the active subscription after webhook events are handled.
To Reproduce
trial_will_endevent.updatedevent because it has the exact same timestamp astrial_will_endeventExpected behavior
Subscription from
customer.subscription.updatedevent should be the last one to be persisted in database, nottrial_will_endAdditional context
Changing this comparison to
<=seems to resolve this issue:https://github.com/supabase/stripe-sync-engine/blob/10955c71fdfb52be84c977ef8ca6b6841c6f0ba3/packages/sync-engine/src/database/postgres.ts#L203