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

Add error boundaries to redux functions #822

Open
ikusteu opened this issue Sep 15, 2023 · 0 comments
Open

Add error boundaries to redux functions #822

ikusteu opened this issue Sep 15, 2023 · 0 comments

Comments

@ikusteu
Copy link
Collaborator

ikusteu commented Sep 15, 2023

Most of firestore related errors will happen in redux functions: either in thunks updating the db, or selectors reading from (would be) corrupt db. Taking this into account, in the spirit of composability, I propose we devise a flow where all redux interactions will be "instrumented" to catch errors, provide fallbacks and report errors, along with the state to sentry.

Thunks

We already have thunk type, but we could write a function createThunk, which would wrap each thunk with an error handler:

  • the handler will try to execute the thunk, if successful, it could, optionally enqueue a success message
  • if the handler fails:
    • it will enqueue an error message (the message provided to createThunk or, if absent, a generic error message)
    • it will send a report to sentry, containing the name of the thunk, the error (with stack trace) and additional metadata: with which params was the thunk called, etc.

Selectors

We could create a wrapper createSelector which will take in a selector function, a fallback (to be returned safely in case of error), wrap the selector so that if it fails, it will return a fallback and send message to sentry, including the stack trace and metadata.

Metadata

As for the metadata, it should, at least, contain the params the thunk/selector was called with. It could return the entire state of the store as well (redux store) and it could, if we chose so, include a context object (like we did in librocco) to provide the full data on which part of the app called it.

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

No branches or pull requests

1 participant