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

perf: run ssrInit() at root layout #19460

Merged
merged 6 commits into from
Feb 25, 2025
Merged

Conversation

hbjORbj
Copy link
Contributor

@hbjORbj hbjORbj commented Feb 21, 2025

What does this PR do?

  • ssrInit() is a function that prefetches i18n translations and some important data (feature flags, team plan, session, user data): https://github.com/calcom/cal.com/blob/main/apps/web/server/lib/ssr.ts#L57
  • ssrInit() is currently ran at (use-page-wrapper)/layout.tsx and (booking-page-wrapper)/layout.tsx
  • It makes more sense to run this in a higher level (app/layout.tsx)

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 🙏.

@graphite-app graphite-app bot requested a review from a team February 21, 2025 19:25
@hbjORbj hbjORbj changed the title perf: run ssrinit at root layout perf: run ssrInit() at root layout Feb 21, 2025
Copy link

vercel bot commented Feb 21, 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 23, 2025 11:12am
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Feb 23, 2025 11:12am

@dosubot dosubot bot added the performance area: performance, page load, slow, slow endpoints, loading screen, unresponsive label Feb 21, 2025
@keithwillcode keithwillcode added consumer core area: core, team members only labels Feb 21, 2025
Copy link

graphite-app bot commented Feb 21, 2025

Graphite Automations

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

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

Copy link
Contributor

github-actions bot commented Feb 21, 2025

E2E results are ready!

export default async function PageWrapperLayout({ children }: { children: React.ReactNode }) {
const h = headers();
const nonce = h.get("x-nonce") ?? undefined;

const context = buildLegacyCtx(headers(), cookies(), {}, {});
const ssr = await ssrInit(context);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

export default async function BookingPageWrapperLayout({ children }: { children: React.ReactNode }) {
const h = headers();
const nonce = h.get("x-nonce") ?? undefined;
const context = buildLegacyCtx(h, cookies(), {}, {});
const ssr = await ssrInit(context);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@@ -56,6 +59,7 @@ export default async function RootLayout({ children }: { children: React.ReactNo
? getFallbackProps()
: await getInitialProps(fullUrl);

const ssr = await ssrInit(buildLegacyCtx(h, cookies(), {}, {}));
Copy link
Contributor Author

@hbjORbj hbjORbj Feb 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added here (higher level in hierarchy)

Copy link
Contributor

@eunjae-lee eunjae-lee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes more sense! I think it's working well on my local machine.

@hbjORbj hbjORbj merged commit 6ea879f into main Feb 25, 2025
46 checks passed
@hbjORbj hbjORbj deleted the perf/run-ssrInit-at-root-layout branch February 25, 2025 11:08
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