stripe / stripe-node

Node.js library for the Stripe API.
https://stripe.com
MIT License
3.9k stars 755 forks source link

Don't mutate error.type during minification #2043

Closed anniel-stripe closed 8 months ago

anniel-stripe commented 8 months ago

The type property on error objects was set to this.constructor.name, which gets mutated during minification. To fix this, explicitly set the type to a hardcoded string for known subclasses of StripeError. This also keeps the default behavior the same in the StripeError parent class for backwards compatibility.

I've added a test project to verify error.type does not get minified when bundling / minifying with esbuild.

Fixes https://github.com/stripe/stripe-node/issues/2042