Skip to content

Conversation

@MehmetAdemi
Copy link
Member

No description provided.

@vercel
Copy link
Contributor

vercel bot commented Oct 11, 2025

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

Project Deployment Preview Comments Updated (UTC)
bugs Ready Ready Preview Comment Nov 7, 2025 2:18pm
remotion Ready Ready Preview Comment Nov 7, 2025 2:18pm

type: 'html',
position: 'right',
value:
'<button aria-label="Ask AI" class="crawlchat-nav-askai header-ask-ai-link" onclick="window.crawlchatEmbed.toggleSidePanel()"></button>',
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
'<button aria-label="Ask AI" class="crawlchat-nav-askai header-ask-ai-link" onclick="window.crawlchatEmbed.toggleSidePanel()"></button>',
'<button aria-label="Ask AI" class="crawlchat-nav-askai header-ask-ai-link" onclick="window.crawlchatEmbed?.toggleSidePanel()"></button>',

The "Ask AI" button's onclick handler doesn't check if window.crawlchatEmbed exists before calling toggleSidePanel(), which will cause a runtime error if the CrawlChat embed script fails to load.

View Details

Analysis

Runtime error in Ask AI button onclick handler when CrawlChat script fails to load

What fails: The "Ask AI" button's onclick handler in packages/docs/docusaurus.config.ts calls window.crawlchatEmbed.toggleSidePanel() without null checking, causing TypeError: Cannot read properties of undefined (reading 'toggleSidePanel') when the external CrawlChat script fails to load.

How to reproduce:

  1. Block the CrawlChat script (https://crawlchat.app/embed.js) via ad blocker, network failure, or CSP
  2. Load the docs website
  3. Click the "Ask AI" button in the navbar

Result: Browser throws TypeError: Cannot read properties of undefined (reading 'toggleSidePanel') in console and button functionality fails

Expected: Button should gracefully degrade when external script unavailable (no error, silent failure acceptable for optional feature)

Fix: Added optional chaining operator (?.) to safely handle undefined window.crawlchatEmbed object, consistent with existing defensive programming patterns in the codebase (e.g., window.location?.origin?.includes() in src/pages/index.tsx).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants