• I haven't made any changes to the WebIDE settings for any of the examples. (for minification - left factory defaults as is - yes?)
    This caused the error: Uncaught SyntaxError: Got UNFINISHED STRING expected EOF at line 1 col 8640

    I'd be almost certain you've definitely changed the Web IDE settings, since the file you gave me doesn't have any 8600 character long lines. 'minification' in settings (the first item) is supposed to say 'No Minification' and I bet it doesn't.

    Just to follow up with what you sent in the PM, as this is probably useful for everyone:

    I said that this was because minification was turned on, and the Web IDE had rammed everything into one giant line of text, which overflowed the available memory and got cropped, not finishing the second string.

    I'm not in agreement that there isn't any managing to finish the second part

    It's not the second string, the line that's printed in the error actually starts thousands of characters from the start of the file . If you take a look under settings->console you should see the code that's actually uploaded.

    It should look a lot like this - I won't post the whole thing in the forum because it's huge:

    "\u0010reset();\n\u0010\u001b[1dfunction­ pageHandler(b,a){u=url.parse(b.url,!0),c­onsole.log('[074] inside MaBe pageHandler u [ '+b.url.toString()+' ]'),console.log('[075] inside MaBe pageHandler u.method [ '+u.method+' ]'),console.log('[076] inside MaBe pageHandler u.host [ '+u.host+' ]'),console.log('[077] inside MaBe pageHandler u.path [ '+u.path+' ]'),console.log('[078] inside MaBe pageHandler u.pathname [ '+u.pathname+' ]'),console.log('[079] inside MaBe pageHandler u.search [ '+u.search+' ]'),console.log('[080] inside MaBe pageHandler u.port [ '+u.port+' ]'),console.log('[081] inside MaBe pageHandler u.query [ '+u.query+' ]'),b.method=='POST'&&
    ...
    '+a.ssid),console.log('[L905] details.mac '+a.mac),console.log('[L906] details.channel '+a.channel);}),setTimeout(onInit,1500);­\n\n"
    

    But DOCTYPE is buried in there towards the end. So when you get this:

    >ERROR: Out of Memory!
    Uncaught SyntaxError: Got UNFINISHED STRING expected EOF
     at line 1 col 8640
    ...Wifi');var C={SSID:'',PAGE:"<!DOCTYPE html><html lang=\"en\"...
                                  ^
    

    You'll notice that the pointer is pointing to the second string on the line, but actually that string starts at nearer column 7700!

    So the fact that the error is at column 8640 means it's at character 940 of your string, when you say your string is about 1k long - so it's cropped.

    Despite the displayed error, the code executes as expected.

    I believe it will have executed everything up until that point. Everything after the declaration of C will have been lost, but presumably that's not used in your code.

    If you were getting the out of memory error all along, that probably explains everything

    When you reduce the code size enough that you get no error, everything executes fine and all functions get added. When you get the error uploading because the code is too big, some functions don't get added and so the final code looks smaller.

    and performing the calculation: 1700 * 12 = 20400 which exceeds the physical capacity of 12284 actual bytes allotted. On to 12288 / 12 = 1024 a rough approximation on the number of 'jsvars' that will fit in the available memory.

    12288 is the amount of bytes in flash - after compression. But yes, 1024 is a reasonable minimum.

    However depending on what code you upload, Espruino can't get 100% usage - see http://www.espruino.com/Performance

    Q: Author note: Still would like to know why 1700 is the magic limit and not around 1024 a calculated value

    It's because 12288 is the amount of Flash, but you have more RAM available. At >1024 vars it's 16 bytes a var, so 1700 * 16 = 27200 bytes.

    Q: Despite indicated remaining memory, has this 8K file reached a perceived capacity limit for this ESP to handle?

    It's because you're trying to upload 8K bytes in one giant line. When Espruino has a string that it has to append to a few characters at a time, it's not as efficient at storage, which explains why it runs out more quickly.

    Q: Is there a suggested limit. e.g. has a known reasonable physical limit been determined?

    It depends on the board, and even on the firmware version. I don't know for sure.


    But just to sum up:

    It looks like there's a 'bug' in minification which causes everything to be put on a single line, but only when 'Minification' is set to 'Esprima (offline)'. It's not the default. Set minification to Closure(online) - Whitespace Only and I bet it'll work perfectly, but the default is actually 'off'.

    I filed a bug for this here: https://github.com/espruino/EspruinoTool­s/issues/61

    But yeah, if you get errors, always look at the very first error, and don't always take subsequent ones at face value :)

About

Avatar for Gordon @Gordon started