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

[dev] Create toasts for console errors and warnings in dev mode. #192412

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

clintandrewhall
Copy link
Contributor

@clintandrewhall clintandrewhall commented Sep 9, 2024

Summary

As titled. This addition will surface any console.warn or console.error messages as toasts in Kibana in dev mode.

Screenshot 2024-09-09 at 5 18 07 PM

This is essentially a pre-requisite for completion of #138222 by surfacing any issues to developers as they work or navigate.

@clintandrewhall clintandrewhall added review dev loe:small Small Level of Effort release_note:skip Skip the PR/issue when compiling release notes impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. backport:skip This commit does not require backporting skip-ci Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) v8.16.0 labels Sep 9, 2024
@clintandrewhall clintandrewhall requested review from a team September 9, 2024 21:29
@clintandrewhall clintandrewhall requested a review from a team as a code owner September 9, 2024 21:29
@elasticmachine
Copy link
Contributor

Pinging @elastic/appex-sharedux (Team:SharedUX)

@clintandrewhall
Copy link
Contributor Author

@spalger - That's one of my better screenshots, if I do say so myself. :elasticheart:

Copy link
Contributor

@Ikuni17 Ikuni17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the plan to revert this after the React upgrade is completed? A method to disable this might be good if it is going to be around for awhile.

@clintandrewhall
Copy link
Contributor Author

clintandrewhall commented Sep 10, 2024

@Ikuni17 I actually want to keep it around. We have lots of warnings and errors that appear in the console-- that are only logged in dev mode-- and live for a very long time without being addressed.

I'm actually curious why we'd disable it, given that we should be in the habit of fixing warnings and errors in our application?

@Dosant
Copy link
Contributor

Dosant commented Sep 10, 2024

Regarding the React upgrade, my concern is a bit different. When we update, we’ll receive a warning for every ReactDOM.render call. This will be very noisy given the number of React trees we have. I don’t think spamming toasts for these warnings would be helpful, as they are expected during this transitional period.

Instead, I wanted to dedupe these ReactDOM.render warnings in the console to minimize noise during the upgrade (print console warning only once)

I also suggest to look at the toast notifications for console messages independently from the React upgrade. So suggest we have as follows:

  • In dev mode, console errors pop up as toasts.
  • Add the ability to mute or ignore specific messages.
  • During the React 17 to 18 transition period, we mute ReactDOM.render toasts and print these warnings only once in the console to avoid having a completely red console
  • After some time when most of Kibana is migrated, we can unmute the ReactDom.render toasts and remove deduplication from console, so that teams that are not helping with the upgrade catch up

@clintandrewhall
Copy link
Contributor Author

@Dosant So the good news is:

  • the interception of warnings and errors gives us the flexibility to do a lot of what you're describing.
    • we could actually suppress a lot of React 18 warnings, if we so chose
    • I think I'll split this logic into a dev package so we can have a lot more granular control of what messages appear
  • toasts already dedupe the error messages, (see below)
Screenshot 2024-09-09 at 5 09 03 PM

I'll take this feedback into account, see if I can clean it up a bit in preparation for what you propose. I think simple regex would be enough to dedupe/suppress some warnings, would you agree?

@clintandrewhall clintandrewhall marked this pull request as draft September 10, 2024 13:57
@elasticmachine
Copy link
Contributor

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!

@Dosant
Copy link
Contributor

Dosant commented Sep 10, 2024

thanks!

I think simple regex would be enough to dedupe/suppress some warnings, would you agree?

yes, sure, even str.startsWith() would be good enough for the particular message I have in mind.

toasts already dedupe the error messages, (see below)

I know, I wanted to suppress/dedupe a particular warning in console also

@Ikuni17
Copy link
Contributor

Ikuni17 commented Sep 10, 2024

@clintandrewhall

I actually want to keep it around. We have lots of warnings and errors that appear in the console-- that are only logged in dev mode-- and live for a very long time without being addressed.

I'm actually curious why we'd disable it, given that we should be in the habit of fixing warnings and errors in our application?

I agree the warnings and errors should be fixed, and it is a good habit to get into. The toasts could even be opt out, but I don't think a dev should be required to use this. They may prefer to have the messages in browser dev tools only. Forcing the dev to see the toasts doesn't necessarily equate to issues being fixed, and some may find it a hinderance.

Also, we likely want to disable this in FTR and Cypress tests to avoid test flake with elements not being visible or clickable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting dev impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. loe:small Small Level of Effort release_note:skip Skip the PR/issue when compiling release notes review skip-ci Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) v8.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants