This is a bit frustrating, but we won't give up. I tried to reproduce the behavior you described, but I couldn't. Analyzing the code, I couldn't find a specific cause that might be creating this problem.
I created a new version! (I'm sorry!),
I added a layer of protection over the battle state to prevent defeat related to summoning and a detailed chain of logs, which can be accessed via the console (f8).
Please download the new version, the file is already updated, and do some tests. If any errors occur, copy the console log and share it here, so we know exactly what's happening.
Some tests can be followed here: