Skip to content

fix: address Sentry performance and runtime issues#15999

Merged
codyde merged 2 commits intomasterfrom
fix/top-sentry-issues
Jan 14, 2026
Merged

fix: address Sentry performance and runtime issues#15999
codyde merged 2 commits intomasterfrom
fix/top-sentry-issues

Conversation

@codyde
Copy link
Copy Markdown
Contributor

@codyde codyde commented Jan 13, 2026

Summary

Addresses top Sentry issues in the docs project:

  • DOCS-A0W (1,264 events): Fix ESM require() error with mdx-bundler
  • DOCS-8BT (1,127 events): Reduce render-blocking JS by lazy-loading components

Changes

DOCS-A0W: mdx-bundler ESM error

Removed mdx-bundler from serverExternalPackages in next.config.ts. The package is ESM-only ("type": "module") and cannot be require()d at runtime on Vercel. The outputFileTracingExcludes already handles excluding heavy build-time parts.

DOCS-8BT: Large render-blocking JS

  • Lazy-load Search component (includes Algolia + global-search) using next/dynamic
  • Lazy-load MobileMenu component (only needed on mobile)
  • Changed Kapa AI script to strategy="lazyOnload"

DOCS-7KN: Large render-blocking CSS

  • Load @radix-ui/themes/styles.css (26K lines) asynchronously via new RadixStyles component
  • Added inline critical styles to prevent complete FOUC while CSS loads
  • Added display: 'swap' to font configuration

Trade-offs

  • Search box shows skeleton loader briefly on initial page load
  • Radix-styled components may flash with minimal styles on first load (cached after)

Testing

Please verify:

  1. Build succeeds
  2. Pages render correctly
  3. Search functionality works after lazy load
  4. Radix components (buttons, etc.) display properly after CSS loads

- Fix DOCS-A0W: Remove mdx-bundler from serverExternalPackages to fix ESM require() error
- Fix DOCS-8BT: Lazy-load Search and MobileMenu components to reduce initial JS bundle
- Fix DOCS-7KN: Load Radix CSS asynchronously to prevent render-blocking
- Optimize Kapa AI script loading with lazyOnload strategy
- Add font display swap for better text rendering

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Jan 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
develop-docs Ready Ready Preview, Comment Jan 13, 2026 10:02pm
sentry-docs Ready Ready Preview, Comment Jan 13, 2026 10:02pm

The dynamic CSS import approach doesn't work - CSS imports are processed
at build time by webpack, not runtime. Reverting to standard static import.

DOCS-7KN (render-blocking CSS) remains unfixed - would require architectural
changes like switching from @radix-ui/themes to unstyled primitives.

Co-Authored-By: Claude <noreply@anthropic.com>
@codyde codyde marked this pull request as ready for review January 14, 2026 03:19
@codyde codyde merged commit d91bf25 into master Jan 14, 2026
16 checks passed
@codyde codyde deleted the fix/top-sentry-issues branch January 14, 2026 03:19
Comment thread app/layout.tsx
</ThemeProvider>
<Script
async
strategy="lazyOnload"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LazyOnload strategy breaks askAI URL parameter feature

Medium Severity

Changing the Kapa AI script from async to strategy="lazyOnload" breaks the ?askAI=true URL parameter functionality. The AskAiSearchParams component in src/components/askAiSearchParams.tsx uses a 300ms timeout to wait for the Kapa script to load before opening the AI modal. With lazyOnload, the script doesn't start loading until after the page is fully loaded and the browser becomes idle—which typically exceeds 300ms—so window.Kapa?.open will be undefined when the timeout fires, and the modal will never open.

Fix in Cursor Fix in Web

@github-actions github-actions Bot locked and limited conversation to collaborators Jan 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants