-
Notifications
You must be signed in to change notification settings - Fork 764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subscription update method mutates items #521
Comments
Hey @jperasmus, thanks for the detailed report! I agree that this sounds like unexpected behavior and should be fixed, but my Node.js expertise is pretty limited. I'm not thrilled about pulling in a new dependency just for this though, even if it's a lodash module. cc @rattrayalex-stripe @jlomas-stripe what do you think? |
Hi @ob-stripe Thanks for the reply. The reason I used the lodash JavaScript, unfortunately, doesn't currently have natively functionality to deeply clone an object, so you could either create a small utility yourself or use something like lodash's In terms of impact on the bundle size, this might give you more insights to help with the decision: https://bundlephobia.com/[email protected] It is definitely not the smallest package. Other smaller options might be https://bundlephobia.com/[email protected] Another quick and dirty way would be to stringify and parse it again, but that can strip out any unserializable properties like functions: |
Thanks for reporting @jperasmus , and for the suggested fix! I'll try to take a look at this today. |
Hi there,
Thanks for this awesome library and for Stripe in general. A-grade 👏
Using:
When performing an update of a subscription's
items
I've discovered that thestripe.subscriptions.update()
method mutates the payload provided to it by transforming theitems
from an array to an object with the array indexes as the object keys. This can lead to very unexpected behaviour when reusing the same payload after the update method was invoked.I've managed to trace the problem to this utility method:
Ideally a new transformed
data
object should be returned instead of mutating it. Something like:The problem would be for any of the other methods that use this utility method and not just for
stripe.subscriptions.update()
.Is this something you would be interested in fixing? I would be happy to create a PR.
The text was updated successfully, but these errors were encountered: