I have exactly the same error! I missed that bugs can be created on Factorio website, and send it in discord directly.
Here is the results of my investigation
The issue occurs at line 652 in companion.lua:
if not target.controller_type or target.controller_type ~= defines.controllers.character then return end
This line doesn't work for vehicles or wagons(and will crash the game since controller_type is a property of LuaPlayer only), as we use this function with those entity types in the code. Here’s my proposed fix:
if target.is_player() and (not target.controller_type or target.controller_type ~= defines.controllers.character) then return end
Since only players have controller_type, this modification makes sense. The code then executes correctly for non-player entities, and I haven’t experienced any crashes for a few hours.