Another possibility is that it could be due to a software problem, which unfortunately is something that Pixel XL owners are experiencing right now. According to reports, it appears that the recent Android 8.1 Oreo update that was rolled out earlier this year has caused an overcurrent charging bug to the original Pixel XL.
This is pretty dangerous because due to the bug, the handset will try to pull up to 40% more current than what the charger is giving it, resulting in it entering and leaving a charging state as the charger attempts to shut itself off to prevent overcurrent charging. However the good news is that those who are using the stock charger shouldn’t have issues as it has been engineered with failsafes to prevent things like this from happening.
For those using third-party chargers, that is a different story because if the charger doesn’t have overcurrent protection then that’s where it gets dangerous. The good news is that Google has since acknowledged the issue where they note, “Tests run by our safety engineers have also confirmed that even if a momentary overcurrent draw of the kind described were to occur in normal-use conditions, it would not pose a safety hazard. In addition, Pixel XL was designed with multiple layers of safety protections to further prevent overheating.”
They also say that they have already found a fix to the bug and expects to roll it out in the coming weeks.