I've been looking in to this and I've found a few issues in Espruino that could be causing this. Hopefully I'll have a new version for you soon with it fixed.
The main issue seems to be really bad timing inside the Bluetooth stack - occasionally you can disconnect, and then the stack will ask Espruino to do something which isn't possible because the device has disconnected!
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I've been looking in to this and I've found a few issues in Espruino that could be causing this. Hopefully I'll have a new version for you soon with it fixed.
The main issue seems to be really bad timing inside the Bluetooth stack - occasionally you can disconnect, and then the stack will ask Espruino to do something which isn't possible because the device has disconnected!