I have run into this, back when my relationship was getting into a really bad place, and when I realized I was unintentionally setting myself up to cheat I completely broke off contact with my new/old flame and made an effort to focus on fixing the problems I had with my actual relationship. It was hard and required a ton of uncomfortable communication between me and my husband, but it was worth the effort.
It’s a really good idea to remind yourself that part of why you’re feeling so giddy and happy about new/old flame is it’s not a real relationship, so you’ve got that “shiny new relationship high” infatuation thing going on, and that never lasts. You do not want to throw a marriage away just to chase that.