Log client-side errors

Created on 13 August 2024, 9 months ago

Overview

The UI application may want to persistently log errors when they occur. Solving this will mean we can add other type of log entries later on, such as warnings, notices, info etc.

Proposed resolution

When 📌 Improve client side error handling Fixed is completed, we'll have an opportunity to log errors from the error boundary component that will be used across the different layers of the UI. A placeholder method is/will be added to do this in ui/src/services/log.ts — already with unit testing in place that mocks this method.

Building on Backend route to allow logging from the UI Active implement the logApi service and call the API endpoint to create the log entries.

Feature request
Status

Active

Component

Page builder

Created by

🇳🇱Netherlands balintbrews Amsterdam, NL

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @balintbrews
  • Status changed to Postponed 9 months ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    📌 Improve client side error handling Fixed is in, but without Backend route to allow logging from the UI Active , this cannot be implemented.

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
  • First commit to issue fork.
  • Merge request !362#3467844: Log client-side errors → (Open) created by omkar-pd
  • Pipeline finished with Failed
    7 months ago
    #308972
  • Pipeline finished with Failed
    7 months ago
    #308983
  • 🇮🇳India omkar-pd

    Started implementing the logApi service.
    Currently, I’ve set up basic logging functionality with a hardcoded level: 'error'. However, I need further guidance on determining the appropriate error level dynamically.

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Tagging for the guidance described as missing in #6.

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
  • 🇳🇱Netherlands balintbrews Amsterdam, NL

    The ability to recover from an issue is what I would consider the main factor when it comes to deciding severity. The error boundaries can catch all kinds of problems, and we can't really predict with full certainty when the UI will be able to recover from those. Therefore I recommend that we go with the level error by default.

    Some errors are thrown, or could be thrown, explicitly by our own code, and while we could implement our own class extending Error and add the severity on a case-by-base basis, I don't see a lot of value in that. We wouldn't be able to make it very granular anyway.

    I would make an exception with the RouteErrorBoundary and RouteAsyncErrorBoundary components. When those components are rendered, it's fully certain that there is no recovery other than reloading the page. I would set the critical level for those.

    I'm curious what others think.

  • Assigned to soaratul
  • Status changed to Needs work 7 months ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    #9++ So error as the default, critical for the 2 special cases.

    That seems like an excellent start. We can refine this in the future. It doesn't need to be perfect. (It can't be perfect yet.)

    Thanks for your guidance, @balintbrews! 🙏

  • First commit to issue fork.
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    To my non-React-trained eyes, this looks great! 😄

    But I'm not seeing any test coverage yet 😅

    Assigning to @balintbrews for review, but I do think this would benefit from an end-to-end test.

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
  • 🇳🇱Netherlands balintbrews Amsterdam, NL

    This is looking great! I requested two code changes. Besides that, as Wim already pointed out correctly in #13, we still need to provide some test coverage for the logging that was added in this MR.

    Ideally we would do that by mocking our `log` module in our existing `ui/tests/unit/error-boundary.cy.jsx` test, but mocking modules in Cypress component tests is problematic, and given we have the ongoing discussion of 📌 Consider dropping Nightwatch in favor of Functional Javascript tests Active , which may result in changing the testing framework of XB in the future, I don't think we should try to solve it. We can still verify the logging in an end-to-end test, there is already one in the repository where we intercept a request and mock an error form the server (`Handles and resets errors` in `ui/tests/e2e/xb-general.cy.js`). That test can be extended to intercept and verify the request sent to `/xb/api/log-error` when the error boundary is rendered.

  • 🇳🇱Netherlands balintbrews Amsterdam, NL
  • Issue was unassigned.
  • Status changed to Needs review 5 months ago
  • First commit to issue fork.
  • Status changed to Needs work 2 months ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    @soaratul is no longer working on Experience Builder.

  • Pipeline finished with Canceled
    2 months ago
    Total: 315s
    #442793
  • Pipeline finished with Canceled
    2 months ago
    Total: 120s
    #442796
  • Pipeline finished with Failed
    2 months ago
    Total: 1176s
    #442798
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    This could help generate much better bug reports 🤞

  • 🇬🇧United Kingdom jessebaker

    I'm marking this as postponed.

    We do not yet have a solution for:

    "When errors happen in the rendering of a React component, they can be hit many many times in quick succession. This will send a call to the server for each and every error. I'm not sure what the solution to that is"

    I think that solution will take some considerable effort to reach. Rate limiting or some how batching identical errors will be required to ensure we don't accidentally spam the server with requests which will only exacerbate any error the user is already facing!

    In addition, once in production, the errors from JS will be pointing to minified/obfuscated JS files which means they will likely be, if not entirely useless, very hard to interpret/action.

Production build 0.71.5 2024