Bug in addon to Change header color dynamically
I think that the issue comes from changing preference data during a UI draw, that is, you are accessing data that should not be altered while drawing the UI.

An alternative approach that seems to work is using handlers to alter the theme settings. In 2.80 the scene_update_* handlers have been renamed to depsgraph_update_*.

def TEST_prefset(scene):
    prefs = bpy.context.preferences

    if scene.tool_settings.use_keyframe_insert_auto == True:
        prefs.themes[0].topbar.space.header = (0.4, 0.000000, 0.000000, 1.000000)

    else:
        prefs.themes[0].topbar.space.header = (0.137255, 0.137255, 0.137255, 1.000000)


def register():
    bpy.app.handlers.depsgraph_update_post.append(TEST_prefset)

def unregister():
    bpy.app.handlers.depsgraph_update_post.remove(TEST_prefset)