This happens to me frequently. It also happens when I am waking in the morning too. That transition period is when it generally happens.
As someone who experienced a lot of childhood trauma, it can be paralyzing. I have gotten used to it now, though it can still cause a moment or two of fright.