[GH-ISSUE #5560] Stripe better-auth onSubscriptionUpdate callback is not returning the updated subscription #18915

Closed
opened 2026-04-15 17:37:59 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @aniravi24 on GitHub (Oct 24, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/5560

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

When updating a subscription in Stripe, the old subscription object prior to the update is being returned in onSubscriptionUpdate calback.

Current vs. Expected behavior

I expect onSubscriptionUpdate to return the latest subscription, and had some code depending on the newly extended subscription.

What version of Better Auth are you using?

1.3.27

System info

{
  "system": {
    "platform": "linux",
    "arch": "x64"
  },
  "node": {
    "version": "v22.20.0",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "10.9.3"
  },
  "frameworks": [
    {
      "name": "react",
      "version": "19.2.0"
    }
  ],
  "databases": [
    {
      "name": "@prisma/client",
      "version": "6.17.1"
    },
    {
      "name": "kysely",
      "version": "0.28.8"
    }
  ],
  "betterAuth": {
    "version": "1.3.27",
    "config": null
  }
}

Which area(s) are affected? (Select all that apply)

Backend, Client, Package

Auth config (if applicable)


Additional context

No response

Originally created by @aniravi24 on GitHub (Oct 24, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/5560 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce When updating a subscription in Stripe, the old subscription object prior to the update is being returned in `onSubscriptionUpdate` calback. ### Current vs. Expected behavior I expect `onSubscriptionUpdate` to return the latest subscription, and had some code depending on the newly extended subscription. ### What version of Better Auth are you using? 1.3.27 ### System info ```bash { "system": { "platform": "linux", "arch": "x64" }, "node": { "version": "v22.20.0", "env": "development" }, "packageManager": { "name": "npm", "version": "10.9.3" }, "frameworks": [ { "name": "react", "version": "19.2.0" } ], "databases": [ { "name": "@prisma/client", "version": "6.17.1" }, { "name": "kysely", "version": "0.28.8" } ], "betterAuth": { "version": "1.3.27", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Backend, Client, Package ### Auth config (if applicable) ```typescript ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-15 17:37:59 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Oct 24, 2025):

This is a known bug in Better Auth v1.3.x: the onSubscriptionUpdate callback receives the subscription object as it existed before the database update, so your code gets stale data after a Stripe subscription update. The root cause is that the webhook handler updates the subscription in the database, but then immediately calls the callback with the original (pre-update) subscription object instead of re-fetching the updated record. This matches your experience and is confirmed in the codebase (source).

Workaround: Patch your webhook handler so that after updating the subscription, you re-fetch the updated subscription from the database and pass that to your callback. For example:

await ctx.context.adapter.update({ ... }); // update subscription
const updatedSubscription = await ctx.context.adapter.findOne<Subscription>({
  model: "subscription",
  where: [{ field: "id", value: subscription.id }],
});
await options.subscription.onSubscriptionUpdate?.({
  event,
  subscription: updatedSubscription,
});

Alternatively, upgrading to the latest Better Auth and Stripe plugin versions may resolve this, as recent PRs have improved subscription update flows (PR #4988). If you can't upgrade, the patch above will ensure your callback gets the latest subscription data.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3445008984 --> @dosubot[bot] commented on GitHub (Oct 24, 2025): <!-- Answer --> This is a known bug in Better Auth v1.3.x: the `onSubscriptionUpdate` callback receives the subscription object as it existed before the database update, so your code gets stale data after a Stripe subscription update. The root cause is that the webhook handler updates the subscription in the database, but then immediately calls the callback with the original (pre-update) subscription object instead of re-fetching the updated record. This matches your experience and is confirmed in the codebase ([source](https://github.com/better-auth/better-auth/blob/8e46b95608c75a4146de31c4c0ae50f3e3a12342/packages/stripe/src/hooks.ts)). **Workaround:** Patch your webhook handler so that after updating the subscription, you re-fetch the updated subscription from the database and pass that to your callback. For example: ```typescript await ctx.context.adapter.update({ ... }); // update subscription const updatedSubscription = await ctx.context.adapter.findOne<Subscription>({ model: "subscription", where: [{ field: "id", value: subscription.id }], }); await options.subscription.onSubscriptionUpdate?.({ event, subscription: updatedSubscription, }); ``` Alternatively, upgrading to the latest Better Auth and Stripe plugin versions may resolve this, as recent PRs have improved subscription update flows ([PR #4988](https://github.com/better-auth/better-auth/pull/4988)). If you can't upgrade, the patch above will ensure your callback gets the latest subscription data. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/71bf0963-5429-451b-b934-de5ba116102a?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/71bf0963-5429-451b-b934-de5ba116102a?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/71bf0963-5429-451b-b934-de5ba116102a?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/71bf0963-5429-451b-b934-de5ba116102a?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/71bf0963-5429-451b-b934-de5ba116102a?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/71bf0963-5429-451b-b934-de5ba116102a?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/71bf0963-5429-451b-b934-de5ba116102a?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/5560)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#18915