Skip to content

Comments

fix: OG image error from custom fonts not being supported#22916

Merged
hbjORbj merged 1 commit intomainfrom
fix/og-image-error-2
Aug 6, 2025
Merged

fix: OG image error from custom fonts not being supported#22916
hbjORbj merged 1 commit intomainfrom
fix/og-image-error-2

Conversation

@hbjORbj
Copy link
Contributor

@hbjORbj hbjORbj commented Aug 6, 2025

What does this PR do?

Problem

  • The Open Graph image generation was throwing Error: Font processing error: lookupType: 5 - substFormat: 3 is not yet supported when Satori (engined used by @vercel/og for image processing) tried to process advanced OpenType features in custom fonts
  • This happens for bookings in Arabic

Solution

  • Replaced Promise.all with Promise.allSettled to gracefully handle font loading failures while maintaining parallel loading performance

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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 6, 2025

Walkthrough

The font loading logic in the handler function was updated to use Promise.allSettled instead of Promise.all for concurrently fetching font files. The revised code checks the fulfillment status of each font fetch operation and selectively includes only successfully loaded fonts in the fonts array. This approach allows the operation to proceed even if some fonts fail to load, by excluding failed font fetches from the final configuration.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/og-image-error-2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@graphite-app graphite-app bot requested a review from a team August 6, 2025 04:56
@keithwillcode keithwillcode added core area: core, team members only foundation labels Aug 6, 2025
@hbjORbj hbjORbj changed the title fix: og image error 2 fix: OG image error from font not being supported Aug 6, 2025
@dosubot dosubot bot added consumer 🐛 bug Something isn't working labels Aug 6, 2025
@graphite-app
Copy link

graphite-app bot commented Aug 6, 2025

Graphite Automations

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

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

@hbjORbj hbjORbj changed the title fix: OG image error from font not being supported fix: OG image error from custom fonts not being supported Aug 6, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/web/app/api/social/og/image/route.tsx (1)

46-57: Font inclusion logic is correct, but consider improving maintainability.

The conditional logic properly checks fulfillment status and includes fonts with appropriate weights. The Cal font being added with both 400 and 600 weights provides good typography options.

Consider using a more descriptive approach to reduce reliance on array indices:

-    const fontResults = await Promise.allSettled([
-      fetch(new URL("/fonts/cal.ttf", WEBAPP_URL)).then((res) => res.arrayBuffer()),
-      fetch(new URL("/fonts/Inter-Regular.ttf", WEBAPP_URL)).then((res) => res.arrayBuffer()),
-      fetch(new URL("/fonts/Inter-Medium.ttf", WEBAPP_URL)).then((res) => res.arrayBuffer()),
-    ]);
+    const fontFetches = {
+      cal: fetch(new URL("/fonts/cal.ttf", WEBAPP_URL)).then((res) => res.arrayBuffer()),
+      interRegular: fetch(new URL("/fonts/Inter-Regular.ttf", WEBAPP_URL)).then((res) => res.arrayBuffer()),
+      interMedium: fetch(new URL("/fonts/Inter-Medium.ttf", WEBAPP_URL)).then((res) => res.arrayBuffer()),
+    };
+    
+    const fontResults = await Promise.allSettled([
+      fontFetches.cal,
+      fontFetches.interRegular, 
+      fontFetches.interMedium,
+    ]);

This would make the intent clearer while maintaining the same functionality.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5d0dc3f and c95d3d4.

📒 Files selected for processing (1)
  • apps/web/app/api/social/og/image/route.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.tsx

📄 CodeRabbit Inference Engine (.cursor/rules/review.mdc)

Always use t() for text localization in frontend code; direct text embedding should trigger a warning

Files:

  • apps/web/app/api/social/og/image/route.tsx
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • apps/web/app/api/social/og/image/route.tsx
🧠 Learnings (1)
📚 Learning: in packages/app-store/office365calendar/lib/calendarservice.ts, the fetcher method in office365calen...
Learnt from: din-prajapati
PR: calcom/cal.com#21854
File: packages/app-store/office365calendar/__tests__/unit_tests/SubscriptionManager.test.ts:0-0
Timestamp: 2025-08-05T12:04:29.037Z
Learning: In packages/app-store/office365calendar/lib/CalendarService.ts, the fetcher method in Office365CalendarService class is public, not private. It was specifically changed from private to public in this PR to support proper testing and external access patterns.

Applied to files:

  • apps/web/app/api/social/og/image/route.tsx
🧬 Code Graph Analysis (1)
apps/web/app/api/social/og/image/route.tsx (1)
packages/lib/constants.ts (1)
  • WEBAPP_URL (12-18)
🔇 Additional comments (3)
apps/web/app/api/social/og/image/route.tsx (3)

38-43: Excellent improvement to font loading resilience!

Switching from Promise.all to Promise.allSettled is a smart change that prevents the entire OG image generation from failing if a single font fails to load. This allows graceful degradation where images can still be generated with whatever fonts are available.


44-44: Good type-safe initialization.

The font array initialization with proper TypeScript typing ensures type safety for the Satori configuration.


62-62: Perfect completion of the resilient font loading implementation.

The dynamic font array assignment ensures that only successfully loaded fonts are included in the configuration, allowing OG image generation to proceed even with partial font loading failures.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 6, 2025

E2E results are ready!

@hbjORbj hbjORbj merged commit a1fc4bc into main Aug 6, 2025
103 of 109 checks passed
@hbjORbj hbjORbj deleted the fix/og-image-error-2 branch August 6, 2025 11:49
pallava-joshi pushed a commit to pallava-joshi/cal.com that referenced this pull request Aug 8, 2025
@coderabbitai coderabbitai bot mentioned this pull request Sep 1, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working consumer core area: core, team members only foundation ready-for-e2e

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants