This just happened to me, on SQL Server 2022 on Windows Server 2022.
I'd applied this month's (2024-July) updates to Windows and SQL onto my passive SQL instance, but not my active SQL instance. In order to test whether the updates are good, I rebooted the active instance, to force it to fail over to the passive instance, that way I could fail it back to the unpatched instance if necessary.
What happened was, the failover worked and SQL server came right up on the passive instance (i.e. it became the active instance), but it refused all connection attempts with the message: "Login failed for user 'so-and-so'. Reason: Server is in script upgrade mode. Only administrator can connect at this time."
I checked task manager and saw that the SQL server process was consuming 8%, i.e. one of its 12 allocated CPUs was running full-tilt, and its memory usage was gradually climbing... sort of like you'd see when compiling a lot of sprocs.
We do have a ton of sprocs, and we do run trace flag -t8032 to increase the size of the procedure cache from ~8GB to ~32GB, so possibly that is related... but in previous failovers I've never seen it take so long to come back up.
It took a grand total of 8 minutes to finish, and return to normal. I probably aged 8 months during that time. But now everything is fine. :/