How long can I leave baby asleep in swing ??

He had been up for 17 hours straight basically crying the whole way through, he will only fall asleep in the swing and when I try to transition to the crib he freaks out. He’s been asleep in the swing for about 4 hours now but I’ve been watching him the whole time, I don’t know what to do at this point and I’m SO exhausted.

Is it bad to leave him in this long??