-
(argh, forum ate a longer response, so just a short answer now:)
Works on my machine :)
My machine now includes ESP8266, ESP32, nRF52. JSON.parse(undefined) doesn't cause a reboot.
Most likely some other code either in the init or in the "regular" part of your program that causes a reboot. Some other error, or stuck in an infinite loop waiting for something that never happens because init failed (and rebooted by watchdog).Even tried this on an ESP8266 (with save to flash)
function onInit(){ print('@onInit'); //throw new Error('b00'); JSON.parse(undefined); }
Output:
____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v01 (c) 2018 G.Williams Espruino is Open Source. Our work is supported only by sales of official boards and donations: http://espruino.com/Donate Flash map 4MB:1024/1024, manuf 0xef chip 0x4016 > Running onInit()... @onInit Uncaught SyntaxError: Expecting a valid value, got undefined at line 1 col 10 undefined ^ in function called from system
And works just fine.
I had similar code in
onInit()
:Instantly after
save()
my ESP8266 went into a reset loop.Is it a specific ESP8266 bug, or is it a general bug?