Sounds like a printer internal problem. If you look into console/log I guess you in deed did send
G28 X0
so if that does not move fully to the x end stop it is an error of the printer. Can e.g. happen through cross talk to the x end stop while homing. So check which cables are close to x end stop sensor. Maybe the heaters are still on and do it while when reset they are off in same position so no cross talk to them.
As intermediate solution you can put in your cancel script several G28 X0 in a row to be sure to reach the end stop. In the long run you need to find the source that triggers the x end stop early.