Skip to content

Events with same timestamps don't persist most recent event data #268

@andrejpavlovic

Description

@andrejpavlovic

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

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

  1. Create a subscription to product with trial.
  2. While in trial update to another subscription.
  3. Note that the following webhook events trigger:
customer.subscription.trial_will_end
customer.subscription.updated
...
  1. The webhook handler updates the subscription from the trial_will_end event.
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions