Skip to content

Conversation

@RafaelSzmarowski
Copy link
Contributor

@RafaelSzmarowski RafaelSzmarowski commented Jan 3, 2022

Goal: The goal for this PR is to create a state in the React implementation to catch and handle untracked errors from Svelte and integrate them into react error boundary. This should be replaced by a global error boundary in Svelte when it will be available.

Context: while investigating on a chart update uncaught error (time scales not accepted by the chartjs chart update method), it appeared that the asynchronous code from the update wasn't caught by Svelte neither by React resulting in a uncontrolled crash. Svelte doesn't offer an error boundary solution for now : github discussion and PR and react error boundaries are not handling asynchronous code as well : react documentation. It appeared that handling specific risky part of the code by wrapping them into a try and catch and setting an error state might be a solution.

Open discussion: this implementation is not ideal as we'll have to add this mechanism specifically for each risky part of the code and gives only a partial safety. A global Svelte error boundary would be better but not yet available. The investigated bug that led to this solution was caused by wrong chartjs parameters sent, we should probably more focus on not allowing this to happen, in this specific case find a solution: chartjs zoom plugin or falling back to a close available time scale. The question is should we keep this error handler as a protection anyway to avoid violent crashes or ignore it and resolve quickly all incoming bugs ?

If the implementation is accepted, what are the other code part we want to wrap with a try and catch and error state ? The markdown rendering ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants