Removing addon get `'NoneType' object has no attribute 'tag_redraw'`

I have a minimal addon example, which I try to install and uninstall through command line (headless blender execution), but get an error in the title.

I install it using commands:

bpy.ops.preferences.addon_install(overwrite=True, filepath='{path_addon}')

without a problem, and I can disable it successfully too:


But when I try removing it:


I always get this error:

Blender 3.0.0 (hash f1cca3055776 built 2021-12-03 00:44:02)
Read prefs: C:\Users\<username>\AppData\Roaming\Blender Foundation\Blender\3.0\config\userpref.blend
addon_utils.disable: test addon not disabled
Error: Python: Traceback (most recent call last):
  File "C:\Program Files\Blender Foundation\Blender 3.0\3.0\scripts\startup\bl_operators\", line 796, in execute
AttributeError: 'NoneType' object has no attribute 'tag_redraw'

location: C:\Program Files\Blender Foundation\Blender 3.0\3.0\scripts\modules\bpy\

Is it a known bug? I have a problem with a large addon, but trying to figure it out I got stuck at this.

I’ve seen this stackexchange post, but it’s quite old and doesn’t really answer my question: python - What does this error mean and is it a Blender bug? - Blender Stack Exchange