fix(Page): handle failed dynamic content loading safely#8006
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
alexander-akait
left a comment
There was a problem hiding this comment.
Please write cypress test for such things
80408f0 to
984a0d7
Compare
|
I've added a Cypress E2E test to verify that a fallback error message is rendered when dynamic content fails to load. |
|
Looks like test doesn't work |
|
I’ve updated the Cypress test again, but it still seems to fail in CI. Could you please point out the correct scenario we should test for the dynamic content failure case? |
|
@mr-baraiya You should test your code, just reproduce your problem |
|
Updated the Cypress test. |
|
I've updated the Cypress test based on your feedback and removed the earlier interception logic. |
|
Just a small follow-up on this PR. The Cypress test has been updated based on the earlier feedback and the interception logic has been removed. All CI checks are passing now. Please let me know if any further changes are needed. Thanks! |
| } else if (content && content.__error) { | ||
| contentRender = ( | ||
| <div className="text-red-600 font-bold">{content.message}</div> | ||
| ); |
There was a problem hiding this comment.
Can we add a test case for this
There was a problem hiding this comment.
Do you mean adding a unit test for the content.__error branch to verify that the error message is rendered?
There was a problem hiding this comment.
Can we get this route on the real site? I feel like we are adding something what never be happened
There was a problem hiding this comment.
This case can occur if dynamic content (MDX import) fails to resolve at runtime — for example:
broken or missing MDX file
network issues during dynamic import
incorrect path or deployment mismatch
Previously, this resulted in a plain string fallback, which breaks the render logic since it expects structured content. This change ensures the component handles such failures safely and avoids runtime crashes by providing a structured fallback
The unit test verifies that this fallback is rendered correctly when such a failure occurs.
3f4a9da to
2b848f6
Compare
test(Page): add unit test for content.__error rendering and fix test setup
e93ef8d to
9cc7c82
Compare
|
I've added a unit test for the |
When
contentis a Promise and fails to resolve, the previous implementation set a plain string as fallback content. However, the render logic expects structured content.This change introduces a safe error object and renders a clear fallback message to prevent potential runtime issues.