Well if the work you were doing is necessary for your company and will enable you to sell your product to other companies it’s not really a loss. If anything it was an opportunity to get real feedback and see where your shortcomings are.
What did you do wrong while closing the enterprise SaaS client?
Probably that you didn’t close the deal in June (or prior to doing any work at all). Alternatively, nothing at all. Maybe you have a great product but your pricing is bad. Maybe you thought these demos were going well but they weren’t. Any number of things. If you were spending 5-6 months working on a product for this client without a contract - don’t do that.
The wrong answer is “CPO’s friend”. That’s your ego speaking.
Maintain close contact, and keep them informed of new product features and ask if you can schedule a demo from time to time for feedback and to see if they like any of the features. Keep a good relationship. Even if it’s with the most junior person on the team. Today’s CPO might not be the future CPO.