Skip to content

perf: Do not import Stripe lib in getServerErrorFromUnknown#19578

Merged
hbjORbj merged 9 commits intomainfrom
perf/stripe-import
Feb 27, 2025
Merged

perf: Do not import Stripe lib in getServerErrorFromUnknown#19578
hbjORbj merged 9 commits intomainfrom
perf/stripe-import

Conversation

@hbjORbj
Copy link
Copy Markdown
Contributor

@hbjORbj hbjORbj commented Feb 26, 2025

What does this PR do?

two reasons for this PR:

  1. When we run functions or routes in Edge where we use getServerErrorFromUnknown, importing stripe lib throws an error because it's incompatible with the Edge Runtime due to its reliance on Node.js-specific APIs like crypto and http
  2. Stripe lib was used only for type check in getServerErrorFromUnknown

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • N/A - I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • Please use the latest Vercel preview and test please 🙏.

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Feb 27, 2025 3:11pm
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Feb 27, 2025 3:11pm

@graphite-app graphite-app bot requested a review from a team February 26, 2025 15:51
@hbjORbj hbjORbj changed the title perf: stripe import perf: Do not import stripe lib in getServerErrorFromUnknown Feb 26, 2025
@hbjORbj hbjORbj changed the title perf: Do not import stripe lib in getServerErrorFromUnknown perf: Do not import stripe lib in getServerErrorFromUnknown Feb 26, 2025
@keithwillcode keithwillcode added consumer core area: core, team members only labels Feb 26, 2025
Comment thread packages/lib/server/getServerErrorFromUnknown.ts Outdated
@graphite-app
Copy link
Copy Markdown

graphite-app bot commented Feb 26, 2025

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (02/26/25)

1 reviewer was added to this PR based on Keith Williams's automation.

@hbjORbj hbjORbj changed the title perf: Do not import stripe lib in getServerErrorFromUnknown perf: Do not import Stripe lib in getServerErrorFromUnknown Feb 26, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 26, 2025

E2E results are ready!

Comment thread packages/lib/server/getServerErrorFromUnknown.ts Outdated
@github-actions github-actions bot marked this pull request as draft February 26, 2025 16:56
@hbjORbj
Copy link
Copy Markdown
Contributor Author

hbjORbj commented Feb 26, 2025

@zomars Let's copy and paste the relevant parts of the source code instead of relying on "any"s

Addressed!

@hbjORbj hbjORbj marked this pull request as ready for review February 26, 2025 17:22
@dosubot dosubot bot added the performance area: performance, page load, slow, slow endpoints, loading screen, unresponsive label Feb 26, 2025
Comment thread packages/lib/server/getServerErrorFromUnknown.ts Outdated
@zomars
Copy link
Copy Markdown
Contributor

zomars commented Feb 26, 2025

Changes look good @hbjORbj. Before merging can we post evidence that a Stripe error is properly being caught and displayed?

zomars
zomars previously approved these changes Feb 26, 2025
@hbjORbj
Copy link
Copy Markdown
Contributor Author

hbjORbj commented Feb 26, 2025

Before merging can we post evidence that a Stripe error is properly being caught and displayed?v

Gottcha

@hbjORbj hbjORbj requested a review from zomars February 27, 2025 14:58
@hbjORbj hbjORbj marked this pull request as ready for review February 27, 2025 14:58
@hbjORbj
Copy link
Copy Markdown
Contributor Author

hbjORbj commented Feb 27, 2025

@zomars Hey Zomar, I added a unit test. Can you reapprove after review?

@hbjORbj hbjORbj enabled auto-merge (squash) February 27, 2025 15:04
@hbjORbj hbjORbj merged commit 4d45aa1 into main Feb 27, 2025
@hbjORbj hbjORbj deleted the perf/stripe-import branch February 27, 2025 15:22
itsalam pushed a commit to itsalam/cal.com that referenced this pull request Mar 6, 2025
…#19578)

* Do not import stripe lib in getServerErrorFromUnknown

* address comment

* remove comment

* add url

* keep the location

* remove space

* add unit test for getServerErrorFromUnknown

* improve
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

consumer core area: core, team members only performance area: performance, page load, slow, slow endpoints, loading screen, unresponsive ready-for-e2e

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants