textual icon indicating copy to clipboard operation
textual copied to clipboard

Fix sporadic NoMatches error reported from Header on app shutdown

Open slawek-es opened this issue 1 year ago • 1 comments

During application shutdown, particularly when running via App.run_test(), it seems that the Header's watcher callback on title or sub_title is called while the Header's children, such as the HeaderTitle, are already unmounted. This results in a NoMatches error being raised.

We fix this by ignoring the NoMatches error, like we did with NoScreen in the recent "hardening" commit 604b04db2.

Please review the following checklist.

  • [x] Docstrings on all new or modified functions / classes
  • [x] Updated documentation
  • [x] Updated CHANGELOG.md (where appropriate)

slawek-es avatar Jul 29 '24 11:07 slawek-es

I tried to follow the issue of NoMatches raised in the Header widget because we have a similar workaround for this problem in our application and I feel responsible for writing this and questioning the changes proposed here.

I may be wrong, but I think this MR is more like a workaround and will hide more significant problems with --probably-- internal task handling?

Please see: https://github.com/Textualize/textual/discussions/4268#discussioncomment-8744192 which reproduced this NoMatches error.

Later it resulted in https://github.com/Textualize/textual/pull/4305 which I tested and I was still able to reproduce NoMatches in the header including these changes.

But such a NoMatches try-catch will hide that error forever when there might be something else (bad) going on. In that case, most developers will probably need to also workaround similar issues with try-catch also, which is not so promising?

mzebrak avatar Jul 29 '24 13:07 mzebrak