Skip to content
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

Don't mutate error.type during minification #2043

Merged
merged 5 commits into from
Mar 21, 2024

Conversation

anniel-stripe
Copy link
Contributor

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 #2042

@anniel-stripe anniel-stripe requested review from a team and richardm-stripe and removed request for a team March 20, 2024 16:13
@anniel-stripe anniel-stripe enabled auto-merge (squash) March 21, 2024 17:07
@anniel-stripe anniel-stripe merged commit 7aaf448 into master Mar 21, 2024
7 checks passed
@anniel-stripe anniel-stripe deleted the anniel-error-types-minified branch March 21, 2024 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

error.type does not survive minification
2 participants