God I really really feel for you. My bf also has a son by his exgf. It's always hard when that 3rd adult is involved in your relationship. I love his son, but his ex gf is a nightmare.
It's hard having a relationship with someone who has that bond with an ex. And I can imagine how heart broken you are to not only loose your bf but his son too. I would be devestated.
I can't give you any brilliant advice, I truely wish I could.
It's hard to compete with the bond that they have. Clearly thoughout the relationship there has been those unresolved feelings and emotions. I'm not sure how much you could have done to protect yourself other than to have walked away when she got pregnant and not taken that chance on him.
It seems that maybe you didn't pick up on the fact that he wasn't not with her because of what they saw as fundamental flaws in their relationship, but rather because of timing/emotions. It doesn't sound like he was very specific in that he knew things wouldn't work and that that's why he wasn't there with her.
I guess my only advice is should you ever find yourself in this type of situation again is to make sure that there are no residual feelings there. That he is not with her, not because she's upset about this or that, but because he knows that long term thier relationship will not work.
My bf is aware that although he loves his son, things would never work out with him and his ex. They have different morals, likes, dislikes, hopes, dreams etc. They live different ways, different lives. As much as he wishes he could be a family for his son, he knows that the family we provide will be a better, happier one. He simply wasn't the best dad he could be when he was with her as he was soooo miserable and unhappy.
Keep your head up, you did the right thing! I hope you feel better soon!!