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

Use reportError() API #6747

Open
1 of 2 tasks
slorber opened this issue Feb 23, 2022 · 0 comments
Open
1 of 2 tasks

Use reportError() API #6747

slorber opened this issue Feb 23, 2022 · 0 comments
Labels
proposal This issue is a proposal, usually non-trivial change

Comments

@slorber
Copy link
Collaborator

slorber commented Feb 23, 2022

Have you read the Contributing Guidelines on issues?

Motivation

Using the new reportError api permits to trigger window.onerror and let users (or error reporting services) to plug their own error handling behavior

https://www.stefanjudis.com/blog/reporterror-a-method-to-report-to-global-event-handlers/

This is not 100% supported though

https://caniuse.com/?search=reportError

React recently merged a PR using this feature

facebook/react#23207

/* global reportError */
export const logRecoverableError =
  typeof reportError === 'function'
    ? // In modern browsers, reportError will dispatch an error event,
      // emulating an uncaught JavaScript error.
      reportError
    : (error: mixed) => {
        // In older browsers and test environments, fallback to console.error.
        // eslint-disable-next-line react-internal/no-production-logging, react-internal/warning-args
        console.error(error);
      };

We should probably do the same and use reportError for any recoverable error that we usually console.error.

There are many places where we deal with recoverable errors, particularly around localstorage usage.

We could eventually expose a core error reporting API that triggers lifecycle a new client module lifecycle event, this could allow users to build error reporting plugins like Sentry?

Self-service

  • I'd be willing to do some initial work on this proposal myself.
@slorber slorber added the proposal This issue is a proposal, usually non-trivial change label Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal This issue is a proposal, usually non-trivial change
Projects
None yet
Development

No branches or pull requests

1 participant