What causes a 500 when stopping a recording?

I am getting 500 errors fairly consistently when calling the API endpoint to stop a recording. It doesn’t happen every time, but very often. I am running OpenVidu in my local dev environment with docker. In my app, recording is stopped and restarted several times in a session. The 500 error happens on about the 3rd stop.

Also, when this happens, the session cannot be deleted, and I get errors when trying to restart recording, presumably because the other recording is still going. Since the session cannot be deleted I have to restart the server.