Some unscientific testing.
Trying a restart after 15 minutes of not doing a restart and the function works as expected
Trying a restart after 50 minutes of not doing a restart and the function fails the first time with the error as mentioned previously.
I can confirm that I encountered this today. It was with a VM that had
been running for several days. I've encountered the same error (or one
similar to it) in the past when trying to shut down a VM that takes a
long time -- Qubes Manager asks me if I want to kill it, and if I say
yes, sometimes there's some apparent race condition and the error comes
up (I guess because the VM finished shutting down right before Qubes
Manager tried to kill it).
For mich I do not see any request to kill the AppVM and the uptime of the VM is very low. for example 50 minutes when I was testing the function to try and get it to error.