huridocs / uwazi

Uwazi is a web-based, open-source solution for building and sharing document collections
http://www.uwazi.io
MIT License
236 stars 79 forks source link

Errors on users custom pages [Timebox 2 days] #5624

Closed Zasa-san closed 10 months ago

Zasa-san commented 1 year ago

Describe the bug Some instances display the error described on #5599 . This is not happening on every instance. The pages show no apparent problems. Checking the error on the browser console yields that this could be a SSR issue. https://legacy.reactjs.org/docs/error-decoder.html/?invariant=425

To Reproduce Steps to reproduce the behavior:

  1. Go to https://cfjustice.uwazi.io/ (the instance mentioned in #5599)
  2. Open the console on the browser
  3. Check the errors on the console

Expected behavior Pages should not have this error.

Device (please select all that apply)

Browser

Additional context A PR was done to hide the error notifications for visitors, since the pages seem to work just fine. But the errors on the console will still appear and logged in users will se the error notification as well. This error started after the PR that upgraded React Router and React.

txau commented 1 year ago

@Zasa-san is this still happening? Can we close this issue?

Zasa-san commented 1 year ago

@Zasa-san is this still happening? Can we close this issue?

There was no development to fix the error, we just made it so that only logged in users would see it. The error is not related with anything that brakes a page, and it only appears in some instances.

I would not close this issue since the underlying problem is not identified yet.

Zasa-san commented 10 months ago

The error seems to be caused by Matomo. The problem was not specially related to custom pages, or custom home page. This error could be observed even when navigating to the settings routes in instances where the common factor is Matomo, and not custom pages. Users that have Matomo but no custom pages would never notice since there is no visible error to let them know that they should check the console. But a blank-state instance with a Matomo configuration will trigger the error.

You can see that the error is triggered in these lines by debugging locally in hot mode and getting the proper info in the console:

https://github.com/huridocs/uwazi/blob/f0d4acb5089c92bc4942cca59df367dd7704b3b9/app/react/App/Matomo.js#L12-L31

There were many SSR errors that started to pop up after upgrading to the latest React Router and React versions. The error itself must be related with the use of dangerouslySetInnerHTML to insert the relevant Matomo scripting, although I would need to look further into why exactly.

Matomo documentation suggests using an effect to insert the relevant code: https://matomo.org/faq/new-to-piwik/how-do-i-start-tracking-data-with-matomo-on-websites-that-use-react/