Ah, that explains why everything halts on entering debugger into the interactive console.
As for the example:
DEBUG: emu.tx print(process.memory().usage)
<
< 158
< =undefined
DEBUG: getSanitizedLastLine: =undefined
> CURRENT MEMORY USAGE NaN
DEBUG: emu.tx print(process.memory().usage)
< 135
DEBUG: getSanitizedLastLine: 135
> CURRENT MEMORY USAGE 135
< 135
> CURRENT MEMORY USAGE 135
The first time there is an =undefined ending up in the last stored line and that is then parsed instead of the 158 the line before. The code sent to the emulator is identical in both cases as the DEBUG: lines show.
The emulator in the web IDE does this too and always so it probably isn't a race but something funky with storing the last line? Maybe a stray \r or something like that...
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.
Ah, that explains why everything halts on entering
debugger
into the interactive console.As for the example:
The first time there is an
=undefined
ending up in the last stored line and that is then parsed instead of the 158 the line before. The code sent to the emulator is identical in both cases as theDEBUG:
lines show.The emulator in the web IDE does this too and always so it probably isn't a race but something funky with storing the last line? Maybe a stray
\r
or something like that...