FIX widget errors caught by error boundary persists after fixing and rerendering #68
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.