I went through a very similar thing with ME/CFS and hEDS (which has a chronic pain component). Before I even knew what was I knew that I was on the decline. I was doing ok at work but my ability to maintain a working pace kept diminishing. I went from full time to part time to less than part time to the occasional contracting. I ended up having to do a bit of a Hail Mary to try to save myself. I took a bunch of stimulants for three months and made some software that I was able to sell for enough money to keep afloat. It was niche software that was obviously going to make money but it was a lot of unpleasant work. I likened it toilet scrubbing work. I knew if it didn't work I'd run out of money and without family support my backup plan was to take a long walk off a short pier. Since then I've been able to find out the underlying problem, no thanks to doctors who were all less than helpful, and now treat it fairly successfully with a variety of meds.
I guess my advice would be, do whatever is needed to make money, no matter how unpleasant, so that you can survive long enough to figure out what is wrong and get treatment. And don't rely on doctors for treatment.