It appears that when you repair any upgrading building (factory, radar, sonar, mex, hive, kennel, etc), you are charged the fixed amount of 10 mass and 10 energy per unit of build capacity. So a t1 com (10 build power) repairing a t1 mex that is upgrading to a t2 mex is charged 100mass and 100energy per second. Obviously for most (all?) buildings this repair will quickly exceed the mass worth of the upgraded building. It is also much more expensive then the upgraded forms of these buildings are to repair.
This is likely the reason you have stalled hard while tending to an upgrading building under fire.