Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined crashes live codeblock #8009

Closed
2 of 7 tasks
isaacbrodsky opened this issue Aug 25, 2022 · 7 comments · Fixed by #8015
Closed
2 of 7 tasks

undefined crashes live codeblock #8009

isaacbrodsky opened this issue Aug 25, 2022 · 7 comments · Fixed by #8015
Labels
bug An error in the Docusaurus core causing instability or issues with its execution good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin.

Comments

@isaacbrodsky
Copy link

isaacbrodsky commented Aug 25, 2022

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

The live codeblock crashes the entire page on inputs that cause React to try to render undefined.

I can work around this by changing transformCode to have an || null in case the code returns undefined.

Reproducible demo

No response

Steps to reproduce

Expected behavior

The entire page does not crash and the code block renders an error instead.

Actual behavior

The entire page (not just the code block) crashes with the error message Minified React error #152; visit https://reactjs.org/docs/error-decoder.html?invariant=152&args[]=n for the full message or use the non-minified dev environment for full errors and additional helpful warnings.

Your environment

Self-service

  • I'd be willing to fix this bug myself.
@isaacbrodsky isaacbrodsky added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Aug 25, 2022
@slorber
Copy link
Collaborator

slorber commented Aug 26, 2022

👍 Couldn't repro on react-live playground: https://react-live.netlify.app/

So this must be a Docusaurus bug 🤷‍♂️

@slorber slorber added good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin. and removed status: needs triage This issue has not been triaged by maintainers labels Aug 26, 2022
@rashidmya
Copy link
Contributor

can I try doing this?

@thelovekesh
Copy link

@rashidmya Can I take this? I have PR ready for this.

@Josh-Cena
Copy link
Collaborator

@rashidmya sure, no need to ask.

In the worst case we just need to add an error boundary. We already have such a component in core.

@rashidmya
Copy link
Contributor

@thelovekesh i'd like to take a shot at this if thats okay

@thelovekesh
Copy link

@rashidmya Ya sure. Since I have looked into this so here are some findings that can help you:

@Josh-Cena
Copy link
Collaborator

I believe we had compatibility issues in the past and ended up pinning the react-live version. I think for now we can simply add an error boundary to display the error gracefully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin.
Projects
None yet
5 participants