Your situation may be different from mine, but here is what I went through and I'll share with you what I wish I had known and done.
Two years ago my husband was unhappy in our marriage. He said there were too many problems, it would never change, and he wanted a divorce, We also separated a few times in the years before that (he'd always leave or move downstairs)... but I convinced him to try one more time and he told me he'd give the marriage a six month trial.
At that time I promised to change, work on the marriage and make it the "best years" ever. I worked very hard to be completely perfect (for him and the marriage. I was like a Stepford Wife!!!!). The six months turned into a year and after about 8 months he met OW and filed for divorce.
So... what do I wish I would have done differently or known? Well... I think that even if I did change and do everything "right" and try to be perfect for him that it may not make a difference (and it didn't!). That I really needed to be a better person for ME. And have a great family for my kids and my self. That I should be his friend but not lose myself in it. That perhaps I should have learned to detach earlier and stopped having expectations of him and let him go... because holding on didn't stop what was going to happen and probably needed to happen. For my husband he had to lose what he had in order to appreciate it. Six months after filing he asked to stop the divorce. He told me he learned a lot during that time and became a different person.
That might not have happened. He might not have changed or he might have decided he liked being single. In the end I learned that it's not 100% on me to fix things. All I can do is my best. I can't always be the glue that holds things together. But I can do things that make me feel good about me and love myself and try to be a good parent for my kids... and try to have a great family regardless of who is in it.
There is no arriving, ever. It is all a continual becoming.