CSCI-SHU-410-SE-Project / Deskulpt

Deskulpt (Desktop + Sculpt, pronounced /'deskʌlpt/), a cross-platform desktop customization tool.
https://csci-shu-410-se-project.github.io/Deskulpt/
MIT License
2 stars 0 forks source link

FIX widget errors caught by error boundary persists after fixing and rerendering #68

Closed Charlie-XIAO closed 3 months ago

Charlie-XIAO commented 3 months ago

Reproducing the error on main

Try an arbitrary widget. Make an error in it that will be caught by the error boundary (for instance, using an undeclared variable in the react component which will give a ReferenceError). You will then see the error display on the canvas. Now fix that error and click re-render in the manager, the error does not go away.

Explanation of the fix

In each error boundary fallback we try to reset the error boundary. I'm not sure about the mechanism behind the issue, but the obvious workaround is to try triggering a re-render. The problem with directly calling resetErrorBoundary in the fall back is that it will go into an infinite re-rendering loop until the error in the widget gets fixed, because it will try resetting, then detects the error, and falls back, and try resetting again. To avoid this we use a flag variable for which the details are in the comments of the code.

Now with this PR try the reproduction steps again. Re-rendering after fixing the error should automatically update the canvas display and render the correct, working widget.

github-actions[bot] commented 3 months ago

✔️ Deskulpt Built Successfully!

Deskulpt binaries have been built successfully on all supported platforms. Your pull request is in excellent shape! You may check the built Deskulpt binaries here and download them to test locally.

Workflow file: .github/workflows/build.yaml. Generated for commit: c3f18c2.

Charlie-XIAO commented 3 months ago

I'm going to merge without approval. This is also unlikely to have OS-specific issues. It is also critical to the developer experience in #66.