cal.com icon indicating copy to clipboard operation
cal.com copied to clipboard

perf: tRPC procedures and middleware refactor

Open roae opened this issue 1 year ago • 6 comments

What does this PR do?

Remove the session and the i18n object from the default tRPC context, to add it in the procedures that are needed, and prevent endpoints that don't need to access the user session from loading unwanted dependencies.

The procedures and middleware were put in separate files, so they are imported only where needed.

Right now this will not have a big impact on performance, but when tRPC is split it will benefit from this.

Fixes #8342

Environment: Staging(main branch) / Production

Type of change

  • Chore (refactoring code, technical debt, workflow improvements)

roae avatar Apr 20 '23 20:04 roae

CAL-1514 Set the user session only on the endpoints where it is needed.

Currently the session is set in the default context of tRPC, this adds the session dependencies to all endpoints. Perhaps, the getServerSession function should be run only in AuthedProcedure, or add SessionProcedure that is in charge of setting the session in the context, in the endpoints where it is necessary.

linear[bot] avatar Apr 20 '23 20:04 linear[bot]

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

Name Status Preview Comments Updated (UTC)
cal ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 9, 2023 7:05pm
ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 9, 2023 7:05pm

vercel[bot] avatar Apr 20 '23 20:04 vercel[bot]

📦 Next.js Bundle Analysis for @calcom/web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

github-actions[bot] avatar Apr 21 '23 00:04 github-actions[bot]

Current Playwright Test Results Summary

✅ 112 Passing - ⚠️ 7 Flaky

Run may still be in progress, this comment will be updated as current testing workflow or job completes...

(Last updated on 05/09/2023 07:23:39pm UTC)

Run Details

Running Workflow PR Update on Github Actions

Commit: 00353b197e0fdebf6f6ddd5c967d7b9ab2a336ea

Started: 05/09/2023 07:09:01pm UTC

⚠️ Flakes

📄   apps/web/playwright/wipe-my-cal.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Wipe my Cal App Test Browse upcoming bookings and validate button shows and triggering wipe my cal button
Retry 1Initial Attempt
0% (0) 0 / 252 runs
failed over last 7 days
1.19% (3) 3 / 252 runs
flaked over last 7 days

📄   apps/web/playwright/reschedule.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Reschedule Tests -- new-booker Should display request reschedule send on bookings/cancelled
Retry 1Initial Attempt
0% (0) 0 / 262 runs
failed over last 7 days
0.76% (2) 2 / 262 runs
flaked over last 7 days

📄   apps/web/playwright/event-types.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Event Types tests user -- old-booker enabling recurring event comes with default options
Retry 1Initial Attempt
0% (0) 0 / 282 runs
failed over last 7 days
1.42% (4) 4 / 282 runs
flaked over last 7 days

📄   apps/web/playwright/booking-seats.e2e.ts • 2 Flakes

Top 1 Common Error Messages

null

2 Test Cases Affected

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Booking with Seats -- new-booker Reschedule for booking with seats -- old-booker Should reschedule booking with seats and if everyone rescheduled it should be deleted
Retry 1Initial Attempt
0% (0) 0 / 297 runs
failed over last 7 days
9.43% (28) 28 / 297 runs
flaked over last 7 days
Booking with Seats -- old-booker Reschedule for booking with seats -- old-booker Should reschedule booking with seats and if everyone rescheduled it should be deleted
Retry 1Initial Attempt
0.68% (2) 2 / 293 runs
failed over last 7 days
3.75% (11) 11 / 293 runs
flaked over last 7 days

📄   packages/embeds/embed-core/playwright/tests/inline.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Inline Iframe - Configured with Dark Theme
Retry 1Initial Attempt
9.14% (16) 16 / 175 runs
failed over last 7 days
9.71% (17) 17 / 175 runs
flaked over last 7 days

📄   packages/embeds/embed-core/playwright/tests/action-based.test.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Popup Tests should be able to reschedule
Retry 2Retry 1Initial Attempt
16.57% (29) 29 / 175 runs
failed over last 7 days
62.86% (110) 110 / 175 runs
flaked over last 7 days

View Detailed Build Results


deploysentinel[bot] avatar Apr 21 '23 00:04 deploysentinel[bot]

No dependency changes detected. Learn more about Socket for GitHub ↗︎


👍 No dependency changes detected in pull request

Pull request alert summary
Issue Status
Install scripts ✅ 0 issues
Native code ✅ 0 issues
Bin script shell injection ✅ 0 issues
Unresolved require ✅ 0 issues
Invalid package.json ✅ 0 issues
HTTP dependency ✅ 0 issues
Git dependency ✅ 0 issues
Potential typo squat ✅ 0 issues
Known Malware ✅ 0 issues
Telemetry ✅ 0 issues
Protestware/Troll package ✅ 0 issues

socket-security[bot] avatar Apr 26 '23 04:04 socket-security[bot]

Left a few comments. Partially done with the review. Will continue later.

Thanks @hariombalhara, by mistake I made commit with changes that should not be uploaded, I will clean up the branch 🙏🏼

roae avatar Apr 26 '23 14:04 roae