Skip to content

fix(docs): Handle missing MDX source files correctly in Edge runtime - #18847

Closed
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/edge-mdx-error-handling
Closed

fix(docs): Handle missing MDX source files correctly in Edge runtime#18847
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/edge-mdx-error-handling

Conversation

@sentry

@sentry sentry Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

DESCRIBE YOUR PR

This PR addresses an issue where requests for non-existent documentation pages (e.g., /docs/changelog) resulted in a 500 Internal Server Error instead of a 404 Not Found.

The root cause was identified in app/[[...path]]/page.tsx. The isExpectedError check, which is intended to gracefully catch 'Failed to find a valid source file' errors thrown when an MDX file is missing, used e instanceof Error. In Edge runtime environments, Error objects crossing VM context boundaries cause instanceof Error to return false. This prevented the error from being recognized as an expected condition, leading to an unhandled exception and a 500 response.

The fix updates the error checking logic in both the main docs and developer docs catch blocks. Instead of relying on instanceof Error, it now checks typeof (e as any)?.message === 'string' && (e as any).message.includes('Failed to find a valid source file'). This ensures the error is correctly identified in Edge environments, allowing the application to return a proper 404 response.

IS YOUR CHANGE URGENT?

Help us prioritize incoming PRs by letting us know when the change needs to go live.

  • Urgent deadline (GA date, etc.):
  • Other deadline:
  • None: Not urgent, can wait up to 1 week+

SLA

  • Teamwork makes the dream work, so please add a reviewer to your PRs.
  • Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it.
    Thanks in advance for your help!

PRE-MERGE CHECKLIST

Make sure you've checked the following before merging your changes:

  • Checked Vercel preview for correctness, including links
  • PR was reviewed and approved by any necessary SMEs (subject matter experts)
  • PR was reviewed and approved by a member of the Sentry docs team

LEGAL BOILERPLATE

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

EXTRA RESOURCES

Fixes DOCS-9WN

Comment @sentry <feedback> on this PR to have Autofix iterate on the changes.

@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
develop-docs Ready Ready Preview Jul 27, 2026 10:53pm
sentry-docs Ready Ready Preview Jul 27, 2026 10:53pm

Request Review

@sfanahata

Copy link
Copy Markdown
Contributor

Previous fix was clearly broken, so this does need repair. The proposed fix would work, but it is flimsy, and a bit bulky. Creating a new PR to address what looks like a larger issue.

  1. Use of as any causes repetition, and could be replaced with a type guard function.
  2. String matching 'Failed to find a valid source file' will fail the moment the string is changed. It looks like a .code property should be catching these as 404s, but something deeper is going on. It would be more ideal if the LLM could question one layer down as to why the thing is failing in the first place.
  • Is this a problem Seer could ever fix?
    • Yes, I believe with more context and a stronger LLM, a more ideal fix would have been presented.
  • Is this a good use of Seer — the kind of problem where a good LLM fix would actually be useful?
    • Yes, this would be a good use of Seer. It's a concrete, knowable fix that can easily be researched and implemented. It also addresses 400k instances, which is significant!

@sfanahata sfanahata closed this Jul 29, 2026
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