From the side of someone who'd be depending on it, roughly in this order:
KNOWN_LIMITATIONS before the tests. It shows you know where the edges are, and it's the fastest way for me to check whether my setup falls inside them.
What happens when it's wrong. Sync will drift at some point, so I want the reconcile rules spelled out: Stripe is the source of truth, and does it overwrite local rows or flag the difference first?
The schema. If the tables are plain and documented, I can query them directly and walk away later, which makes the dependency much smaller.
Copy vs package: for billing I'd copy it, or at least pin an exact version. I want to read every line that touches subscription state, and I don't want a minor bump changing how a cancel is handled.
Edge cases I'd ask about: a trial that converts but the first invoice fails, pauses, and mid-cycle plan changes with proration, where the subscription can show the new plan before that invoice is paid unless you use pending updates.
What would make me write it myself: if the library also decided access. Mirroring Stripe is generic; who gets what is product logic and belongs in my code.
Thanks Arthur, this is the most useful list yet. On reconcile: it overwrites the local row with what Stripe says, through the same revision-checked write a webhook uses. It does not flag first. A report-only mode is the second request for that today, so I'll add it. The schema is plain tables in sql/schema.sql, nothing hidden. On access: the library mirrors Stripe state, and the entitlement policy is one replaceable file, so your product rules stay in your code. Pauses and mid-cycle proration aren't covered in KNOWN_LIMITATIONS yet and I haven't run them against real Stripe, so treat them as unverified. I'll add them there.
Follow up on your question about flagging before overwriting: reconcile can now do that. previewReconcile and previewReconcileRecent list what would change (the stored value next to Stripe's) and write nothing. The real reconcile still overwrites, so the preview is the flag-first step. It's on main, with the one gap in KNOWN_LIMITATIONS: a preview can't see an owner mismatch.
Software engineer who builds things that run in production — and writes deep-dive guides on why they break. I explain how React, Node, Docker, Rust and Kubernetes actually work under the hood.
Hey naval! 'replays late, duplicate, and out-of-order events' lol that's the demo I'd run first. I watched my own sync code fail the duplicate one once, same event twice, user got credited twice. twice!! fixed it with a boring little dedupe table and a lot of shame. on writing it myself, if there's no dry-run for the reconcile I'd probably still roll my own tbh. thanks for the honest limitations file :)
Ha, the credited twice one is a classic. There's no dry-run on reconcile yet, and that's fair feedback. Right now it writes and then reports counts. Would a report-only mode that lists what it would change (the row, Stripe's state, the difference) and writes nothing be what you'd want before trusting it? I'd add it as an issue and credit you.
Software engineer who builds things that run in production — and writes deep-dive guides on why they break. I explain how React, Node, Docker, Rust and Kubernetes actually work under the hood.
Follow up: the report-only reconcile you asked about is in now. previewReconcile and previewReconcileRecent fetch from Stripe, compare with your rows and list what would change (the stored value next to Stripe's), without writing anything. It's on main and in the RUNBOOK. One gap: a preview can't see an owner mismatch that a real run would report.
Software engineer who builds things that run in production — and writes deep-dive guides on why they break. I explain how React, Node, Docker, Rust and Kubernetes actually work under the hood.
previewReconcile is exactly the bit I meant.. my row on one side, Stripe's on the other, nothing writes. I lost a whole evening once to a subscription that said active in my db and canceled in Stripe, still no idea which webhook I missed
owner mismatch gap, yeah that tracks, a dry run can't know
The demo on a fake Stripe is the strongest trust signal on your list, naval — it lets me see the failure modes without handing you my keys, and that matters more than the tests, because tests only prove the cases you thought of. But the first thing I'd actually check is the reconcile job: how it decides a missed event is really missed, and what it does when Stripe and Postgres disagree after the fact. A sync library lives or dies on that one decision.
On your questions: I'd install it as a package if the upgrade path is clean, but copy it in if the logic is small enough to own — billing code I can't read in an afternoon is billing code I don't trust. The edge case that worries me most is the one you named: a late update after a delete. What does your module do when a subscription.updated arrives after subscription.deleted — resurrect the row, or drop it and log it?
And the 'write it myself' line for me: no story for what happens when the reconcile job itself crashes halfway. What's the recovery there?
Late update after a delete: once Stripe shows a terminal state the row is tombstoned and never changes again, so the late update is skipped and logged, not resurrected. Reconcile crash halfway: each subscription is its own claim and write, so finished ones stay written and the rest are untouched. Re-run with the same since date and it redoes the rest, skipping rows that already match Stripe. Missed events: it lists Stripe's events since a date, re-fetches each subscription once and writes only if Stripe differs. Stripe keeps events about 30 days. Details are in docs/SYNC_MODEL.md.
We're a place where coders share, stay up-to-date and grow their careers.
From the side of someone who'd be depending on it, roughly in this order:
Copy vs package: for billing I'd copy it, or at least pin an exact version. I want to read every line that touches subscription state, and I don't want a minor bump changing how a cancel is handled.
Edge cases I'd ask about: a trial that converts but the first invoice fails, pauses, and mid-cycle plan changes with proration, where the subscription can show the new plan before that invoice is paid unless you use pending updates.
What would make me write it myself: if the library also decided access. Mirroring Stripe is generic; who gets what is product logic and belongs in my code.
Thanks Arthur, this is the most useful list yet. On reconcile: it overwrites the local row with what Stripe says, through the same revision-checked write a webhook uses. It does not flag first. A report-only mode is the second request for that today, so I'll add it. The schema is plain tables in sql/schema.sql, nothing hidden. On access: the library mirrors Stripe state, and the entitlement policy is one replaceable file, so your product rules stay in your code. Pauses and mid-cycle proration aren't covered in KNOWN_LIMITATIONS yet and I haven't run them against real Stripe, so treat them as unverified. I'll add them there.
Follow up on your question about flagging before overwriting: reconcile can now do that. previewReconcile and previewReconcileRecent list what would change (the stored value next to Stripe's) and write nothing. The real reconcile still overwrites, so the preview is the flag-first step. It's on main, with the one gap in KNOWN_LIMITATIONS: a preview can't see an owner mismatch.
Hey naval! 'replays late, duplicate, and out-of-order events' lol that's the demo I'd run first. I watched my own sync code fail the duplicate one once, same event twice, user got credited twice. twice!! fixed it with a boring little dedupe table and a lot of shame. on writing it myself, if there's no dry-run for the reconcile I'd probably still roll my own tbh. thanks for the honest limitations file :)
Ha, the credited twice one is a classic. There's no dry-run on reconcile yet, and that's fair feedback. Right now it writes and then reports counts. Would a report-only mode that lists what it would change (the row, Stripe's state, the difference) and writes nothing be what you'd want before trusting it? I'd add it as an issue and credit you.
yes naval!! that mode lol... 1am pen-and-paper me approves xD look first, write after
Follow up: the report-only reconcile you asked about is in now. previewReconcile and previewReconcileRecent fetch from Stripe, compare with your rows and list what would change (the stored value next to Stripe's), without writing anything. It's on main and in the RUNBOOK. One gap: a preview can't see an owner mismatch that a real run would report.
naval!! you actually built it haha, thank you
previewReconcile is exactly the bit I meant.. my row on one side, Stripe's on the other, nothing writes. I lost a whole evening once to a subscription that said active in my db and canceled in Stripe, still no idea which webhook I missed
owner mismatch gap, yeah that tracks, a dry run can't know
pulling main after dinner and trying it :D
The demo on a fake Stripe is the strongest trust signal on your list, naval — it lets me see the failure modes without handing you my keys, and that matters more than the tests, because tests only prove the cases you thought of. But the first thing I'd actually check is the reconcile job: how it decides a missed event is really missed, and what it does when Stripe and Postgres disagree after the fact. A sync library lives or dies on that one decision.
On your questions: I'd install it as a package if the upgrade path is clean, but copy it in if the logic is small enough to own — billing code I can't read in an afternoon is billing code I don't trust. The edge case that worries me most is the one you named: a late update after a delete. What does your module do when a subscription.updated arrives after subscription.deleted — resurrect the row, or drop it and log it?
And the 'write it myself' line for me: no story for what happens when the reconcile job itself crashes halfway. What's the recovery there?
Late update after a delete: once Stripe shows a terminal state the row is tombstoned and never changes again, so the late update is skipped and logged, not resurrected. Reconcile crash halfway: each subscription is its own claim and write, so finished ones stay written and the rest are untouched. Re-run with the same since date and it redoes the rest, skipping rows that already match Stripe. Missed events: it lists Stripe's events since a date, re-fetches each subscription once and writes only if Stripe differs. Stripe keeps events about 30 days. Details are in docs/SYNC_MODEL.md.