Events with same timestamps don't persist most recent event data
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- postgresql, typescript
Research direction
Start at packages/sync-engine/src/database/postgres.ts around line 203 and inspect the timestamp comparison used when webhook events update subscriptions. Reproduce the trial-to-another-subscription sequence, verify that trial_will_end and updated can share a timestamp, and confirm the updated event's subscription is the value persisted in Postgres.
Written by the indexing model from the issue text.
Description
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
- 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_endevent. - The webhook ignores the subscription from
updatedevent because it has the exact same timestamp astrial_will_endevent
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
- Dominant language
- TypeScript
- Stars
- 1.1k
- Forks
- 117
- Avg merge
- 12m
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from stripe/sync-engine
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
stripe/sync-engine#331 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
stripe/sync-engine#346 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 67/100
stripe/sync-engine#337 · 1 comment · 2 reactions ·
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
stripe/sync-engine#336 · 3 comments · 2 reactions ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
stripe/sync-engine#332 · 1 comment ·
All issues in stripe/sync-engine
Similar issues
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 76/100
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
vercel/react-tweet#225 ·