docusaurus icon indicating copy to clipboard operation
docusaurus copied to clipboard

added error boundary to playground

Open rashidmya opened this issue 3 years ago • 10 comments

Pre-flight checklist

  • [x] I have read the Contributing Guidelines on pull requests.
  • [ ] If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • [ ] If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

Fixes page crashing when typing undefined or {} in live editor

Test Plan

Test links

Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/

Related issues/PRs

#8009

rashidmya avatar Aug 27 '22 17:08 rashidmya

Hi @rashidmya!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

facebook-github-bot avatar Aug 27 '22 17:08 facebook-github-bot

[V2]

Name Link
Latest commit fd54f123fd2893ef017b0078028982895002d780
Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/6348307e1bd1f50009097c52
Deploy Preview https://deploy-preview-8015--docusaurus-2.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Aug 27 '22 17:08 netlify[bot]

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 58 🟢 98 🟢 100 🟢 100 🟢 90 Report
/docs/installation 🟠 88 🟢 100 🟢 100 🟢 100 🟢 90 Report

github-actions[bot] avatar Aug 27 '22 17:08 github-actions[bot]

Note, we already have an error boundary component in core: https://docusaurus.io/docs/docusaurus-core#errorboundary Please just reuse this one

Josh-Cena avatar Aug 27 '22 17:08 Josh-Cena

using error boundary component in core results in this behavior inside the live editor. is that okay?

Capture

rashidmya avatar Aug 27 '22 18:08 rashidmya

You should provide a custom fallback.

Josh-Cena avatar Aug 27 '22 18:08 Josh-Cena

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

facebook-github-bot avatar Aug 27 '22 18:08 facebook-github-bot

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

facebook-github-bot avatar Aug 27 '22 18:08 facebook-github-bot

Its working correctly now. any notes?

rashidmya avatar Aug 28 '22 16:08 rashidmya

Capture is this better?

I had difficulty figuring out how to reuse the LiveError component

rashidmya avatar Sep 01 '22 11:09 rashidmya

@slorber why does CI fail when I added styles for the component

rashidmya avatar Sep 20 '22 07:09 rashidmya

@slorber why does CI fail when I added styles for the component

The CI says it: you just added an extra ! in the tryAgain button label, and we end up with 2 buttons in our theme with the same key but different labels which we should avoid.

LGTM 👍 just did minor fixes


Note I tried to do some kind of "auto try again on code change" behavior but it's complicated because it seems const {code,error} = useContext(LiveContext) does not update for some reason when code string contains error, so the auto retry is hard to trigger with an effect.

Also we still have weird annoying cases where both the live error and the error boundary crash are displayed at the same time. Tried to improve but react-live does not make it very easy unfortunately

When code change from "crash" to "react-live-error" state, both are displayed. Unless we find a way to autoretry the error boundary I think it's better to display the live error in addition (even if it's weird) rather that staying on the rough error boundary crash message:

CleanShot 2022-10-13 at 17 41 24@2x

Those are edge cases, probably not worth investing a lot of time on these atm

slorber avatar Oct 13 '22 15:10 slorber