Twitter crashes itself with commas

Today Twitter died in Opera while I was using it. One tweet sent, one distracting link read – and all of a sudden the UI was incomplete, missing the "Tweet" box on the left and various features like "retweet" were no longer working.

Oh well, I thought. Probably because I'm using some alpha-extra-unstable-work-in-progress internal build.. Let's see..

But no such luck. Twitter was equally dead in 12 final, and there was an ominous error in the console:

EcmaScript
Syntax error at line 1 while loading: input too deeply nested
lineRecommendations",function(a){using("
--------------------^
URL: https://si0.twimg.com/c/phoenix/en/bundle/t1-more.5d72926b785051d84927ae194c9a7bfd.js
Context: Linked script compilation

A compile error?! Uh-oh, that doesn't sound good. It means Opera fails before it even starts running the JavaScript. And what a script.. that "bundle/t1-more" file is a whopping 4 129 653 characters. I'd struggle a bit having to compile that too..

What causes the problem is however not the number of characters, but the fact that most of the file is function calls that are separated by commas. In effect, almost all the four million characters becomes a single JavaScript statement. There are 1048 instances of ),provide( and Opera chokes on the 1019th.

I've seen a few sites use commas instead of semi-colons in their JavaScript lately. Why this fashion is catching on is beyond me – it has drawbacks like making it a lot harder to use the current JavaScript debuggers on the code. And here it unfortunately hits a limit in Opera's code parser, so compilation failed and Twitter basically stopped working.

We already knew that we had a limitation that other browsers don't have in the parser, and it was already considered important to fix. Breaking Twitter of course raises the profile of this bug. But while we work on the parser, a new browser.js stopgap patch will hopefully ensure that users never notice this problem. All it does is to change a single of those commas before the limit is hit to a semicolon, and that makes everything work again..

Advertisements

24 thoughts on “Twitter crashes itself with commas

  1. So, are you saying that the js file for this section of Twitter is 4MB? If so, that's ludicrous! And a good reason to leave the adverts behind and use another Twitter client! ')

  2. For about a month I can not check for updates."Error while checking for updates"last version isvar bjsversion=' Opera Desktop 12.00 core 2.10.289, June 18, 2012. Active patches: 207 ';

  3. Originally posted by artyname:

    I believe it's Google Closure compiler putting commas in there.

    90% sure it's Uglify rather than Closure Compiler. Uglify really likes that trick, and I haven't seen it much with my CC minified code.

  4. Could this have something to do with twitter suddenly counting many thousands new tweets on my timeline in just a few seconds? I follow rougly 300 twitterers. I videotaped it.

  5. Originally posted by petercooperuk:

    I don't know the definite "reason" it came into JS but many elements of C did and this was one of them.

    It's commonly used to supply multiple parameters in a for loop.

    for(var i=0, j=3; ...; ...) { ... }
  6. lol well one of their devs is against using semicolons (bootstrap guy – unless he's trolling with the bootstrap code like I've also heard) so I guess that tendency is permeating back into Twitter.

  7. Originally posted by Astrophizz:

    It looks like it means the parser bug was fixed so Opera should be more compliant now.

    OK yes, but really – will it be part of Opera 12.01 or will go straight into 12.50?

  8. Originally posted by Swapnil99pro:

    will it be part of Opera 12.01 or will go straight into 12.50?

    It will certainly be in 12.50, but IMHO the workaround by Twitter and the site patch means that there is no great urgency getting the core fix into 12.01. Getting the fix that leaves Facebook hanging in a never-stops-loading condition quickly into users' hands is way more important, for example.

  9. Very interesting read (together wih one about google maps).Couple of questions:1) Does the comma trick have an impact on JS performance?1A) If "yes", have you considered talking with UglifyJS dev team?2) 4 megabytes sounds like a lot. What are current (soft) limits of js code size, that developer should be beware of? (At least for Opera).

  10. HelloMy name is Cynthia and i seek for true friendship andpartner so i contacted you, please if you don't mind i will likeyou to reply my mail back so i can send you my pictureand tell you more about me,Cynthia……my email..(cynthiajobe@hotmail.com)Kisses

  11. Originally posted by c69:

    1) Does the comma trick have an impact on JS performance?

    None I'm aware of.Originally posted by c69:

    2) 4 megabytes sounds like a lot. What are current (soft) limits of js code size, that developer should be beware of?

    4 megabytes is indeed a lot and to be honest, I don't understand either why they would write so much JS for a service that appears to be relatively simple. But I guess simplicity is only skin deep ;)We used to have more constraints and limitations in our older ES engine, the "Futhark" one. However, these days I believe the amount of code we can parse and run is limited by the machine's RAM and the end user's patience – the latter probably being a more scarce resource than the former.Finally, the comma fix is in for the 12.01 update. Yay! 😎

  12. It's been a long time and a few versions back, but I recall commas being used for strings and substrings. I often use Mozilla's debugger that throws warnings for the use of older code that I once used and many still use today. Especially in user submitted add-ons.For those unfamiliar with the debugger, it debugs HTML, CSS, and JavaScript. It is a console that gives three levels; inf ormation, warning, and error. It is not a true debugger, in that it only gives information. It does not stop scripting; that is handled internally by the scripting engine.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s