Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

Fixes FER-[ticket number needed]

Changes Made

This PR fixes the 404 page to always show route suggestions. Previously, users would see "Finding similar pages..." but no suggestions would appear.

Root cause: The getRouteSuggestions server action was failing with a runtime error because the not-found routes were running on Edge runtime but importing Node-only modules (@fern-api/docs-loader, getDocsHostApp).

Solution:

  1. Added export const runtime = "nodejs" to both not-found.tsx files to force Node runtime
  2. Added client-side fallback suggestions that generate parent paths when server suggestions fail or return empty results

What was the motivation & context behind this PR?

Reported by @dannysheridan in Slack thread. When users hit 404 pages like:

  • https://buildwithfern.com/learn/sdks/overview/custom-cod
  • https://buildwithfern.com/learn/sdks/autopilot

The page showed "Finding similar pages..." but never displayed suggestions. Browser console showed server component render errors.

How has this PR been tested?

⚠️ This PR has NOT been tested in a running environment. The fix is based on:

  • Analysis of browser console errors showing server action failures
  • Reviewing the code to identify the runtime mismatch issue
  • Following Next.js best practices for server actions with Node-only dependencies

Review Checklist

Critical items to verify:

  1. Test in preview deployment - Verify suggestions actually appear on 404 pages
  2. Validate fallback paths - Ensure parent path suggestions (e.g., /learn/sdks from /learn/sdks/overview/custom-cod) lead to valid pages, not additional 404s
  3. Performance impact - Confirm forcing Node runtime for 404 pages is acceptable (vs Edge runtime)
  4. Error scenarios - Test both:
    • Server action failing (should show fallback suggestions)
    • Server action returning empty (should show fallback suggestions)
    • Server action succeeding (should show server suggestions)

Questions for reviewers:

  • Is runtime = "nodejs" the right solution, or should we move this to an API route instead?
  • Should we add analytics/Sentry tracking for when fallbacks are used vs server suggestions?
  • Should fallback suggestions be smarter (e.g., check if parent paths exist before suggesting them)?

Link to Devin run | Requested by @dannysheridan

- Add runtime = 'nodejs' to not-found.tsx files to fix server action runtime mismatch
- Add client-side fallback suggestions based on parent paths when server suggestions fail
- Ensures suggestions always appear on 404 pages even if server action errors

Co-Authored-By: [email protected] <[email protected]>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@vercel
Copy link
Contributor

vercel bot commented Nov 2, 2025

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

Project Deployment Preview Updated (UTC)
dev.ferndocs.com Ready Ready Preview Nov 2, 2025 9:23pm
fern-dashboard Ready Ready Preview Nov 2, 2025 9:23pm
fern-dashboard-dev Ready Ready Preview Nov 2, 2025 9:23pm
ferndocs.com Ready Ready Preview Nov 2, 2025 9:23pm
preview.ferndocs.com Ready Ready Preview Nov 2, 2025 9:23pm
prod-assets.ferndocs.com Ready Ready Preview Nov 2, 2025 9:23pm
prod.ferndocs.com Ready Ready Preview Nov 2, 2025 9:23pm
1 Skipped Deployment
Project Deployment Preview Updated (UTC)
fern-platform Ignored Ignored Nov 2, 2025 9:23pm

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.

1 participant