Just to add to this - Espruino is designed for 'normal' microcontroller systems where most IO processing happens in interrupts. When systems work like that, having a long-running function isn't a problem at all.
The Nordic bluetooth chips are a great example of this - they handle all the Bluetooth/IO stuff in interrupts and everything 'just works'.
However on ESP8266 a lot happens in tasks that are all executed at the same priority level. If one task (eg. Espruino) takes too long it can mess up WiFi, so they added a watchdog timer that resets the system if that happens.
There's not really much of a way around it - you can add multi-tasking, but then that uses up a bunch of memory for an execution stack and means that you don't have enough to run a sensible amount of JS code. At the end of the day Espruino+ESP8266 is never going to be perfect - but I think for a lot of things it's more than good enough.
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.
Just to add to this - Espruino is designed for 'normal' microcontroller systems where most IO processing happens in interrupts. When systems work like that, having a long-running function isn't a problem at all.
The Nordic bluetooth chips are a great example of this - they handle all the Bluetooth/IO stuff in interrupts and everything 'just works'.
However on ESP8266 a lot happens in tasks that are all executed at the same priority level. If one task (eg. Espruino) takes too long it can mess up WiFi, so they added a watchdog timer that resets the system if that happens.
There's not really much of a way around it - you can add multi-tasking, but then that uses up a bunch of memory for an execution stack and means that you don't have enough to run a sensible amount of JS code. At the end of the day Espruino+ESP8266 is never going to be perfect - but I think for a lot of things it's more than good enough.