I'm not sure about xc40 but in SPA cars a broken wire causes same kind of sympthoms. I just had same kind of sympthoms in my V90 and I think this is same kind of case.
The end of the wiring before sensor gets broken from inside the insulation and starting to throw errors randomly. You cannot see the broken part from outside because it is inside the insulation. You have to replace 20-30cm of wiring before the sensor. The crack is somewhere in the section of the wire that moves when wheels are turned. The conductor of the wire is very bad quality copper and you will notice this when soldering new wires for the old ones.
The end of the wiring before sensor gets broken from inside the insulation and starting to throw errors randomly. You cannot see the broken part from outside because it is inside the insulation. You have to replace 20-30cm of wiring before the sensor. The crack is somewhere in the section of the wire that moves when wheels are turned. The conductor of the wire is very bad quality copper and you will notice this when soldering new wires for the old ones.

