medic / cht-core

The CHT Core Framework makes it faster to build responsive, offline-first digital health apps that equip health workers to provide better care in their communities. It is a central resource of the Community Health Toolkit.
https://communityhealthtoolkit.org
GNU Affero General Public License v3.0
469 stars 217 forks source link

chore(#9561): refactor services to fix cht-from error #9647

Closed jkuester closed 1 day ago

jkuester commented 1 week ago

Description

Closes https://github.com/medic/cht-core/issues/9561

More details on source of the problem are in the issue, but TLDR is that a dependency on the changes.service leaked into cht-form. The changes.service tries to listen to the db for changes and prints an error if it cannot, before re-trying to listen again. In cht-form, there is no db to listen to and the result is that when cht-form runs, the changes.service code just contantly spams error messages to the logs.

My fix here is to update the service dependency tree to move some code out of the extract-lineage.service (which the enketo.service needs) and put it in the user-contact.service. This essentially removes the dependency on the changes.service (and a number of other things not needed by enketo.service). I think the user-contact.service is a reasonable place for this functionality anyway, but I am happy to hear other ideas for how to address this!

Additionally, I have added an after-hook to the cht-form integration tests to validate the browser console and check for any unexpected logs. Hopefully this will help catch issues like this in the future.

Code review checklist

Compose URLs

If Build CI hasn't passed, these may 404:

License

The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.

latin-panda commented 4 days ago

Thanks @jkuester! I'll review this tomorrow. How can I reproduce the issue? Will any form submission in the default config do?

jkuester commented 3 days ago

Thanks! To repro this issue basically all you have to do is open a form using cht-form (e.g. https://github.com/medic/support-scripts/tree/master/cht-form-example ) and check the browser console logs and you should see the errors.