For me, what works is an ADHD medication along with not trying to fall asleep. Trying to fall asleep causes me something in the area of anxiety and guilt, so I end up frustrating myself awake. If I focus on a mindless task like scrolling through Lemmy or reading a book, I get engaged in that and end up accidentally falling asleep. The funny thing is that I have to keep doing my mindless task until I fall asleep, so many times, I wake up looking like I passed out in the middle of something with my glasses still on and my phone laying around. I'm actually curiously impressed that my glasses or phone haven't broken yet.
I feel you bro/sis, except the glass part. I woke up over a phone or a laptop to discover what random things my body did. Once I was debugging a crashing function and waking up I saw the offending test passed. It took a while to discover that the 'miracle' was my asleep body deleting some other code somewhere in the callchain ;)