How One Missing `var` Ruined our Launch
11–20 of 223 posts
Re: How One Missing `var` Ruined our Launch
#12Re: How One Missing `var` Ruined our Launch
#13Am I right in thinking that the javascript /* "use strict" */ construct would have caught this mistake (just like it would have done for me in perl code)? Seems to me that some such feature is absolutely and utterly necessary in any environment where you're doing a lot of closure creation ..
$ node
> "use strict"; initial = "foo";
ReferenceError: initial is not defined
at repl:1:17
at Interface. (repl.js:168:22)
...Re: How One Missing `var` Ruined our Launch
#14Re: How One Missing `var` Ruined our Launch
#15Reminds me of one of the more confusing bugs I've ever encountered in my life. I was throwing together a quick UI with Adobe Flex, and for some reason every time you clicked a particular button, the entire UI would shift 20 or so pixels to the right. I spent hours scratching my head until I noticed this for loop: for (x=0;x I wasn't declaring the x variable, so it was using the x part of the x/y positioning of the UI…
Re: How One Missing `var` Ruined our Launch
#16Re: How One Missing `var` Ruined our Launch
#17But the problem is a bit more meta than Javascript scoping. Something would have happened no matter your environment. It's always extremely risky to make huge changes just before a launch day. Stuff always breaks. Sounds like you did a good job of communicating with your customers. Ironically, they will probably be better customers than they would have been if you didn't have any problems. Overcoming adversity brings people together.
Add some concurrency to your test suite. If you have any system level or black box tests, you can often just run the same test multiple times in parallel with different threads. No new tests required. Note that this may (probably will) also uncover other previously inconceivable concurrency issues.
Re: How One Missing `var` Ruined our Launch
#18Since everyone is chiming in with ways to prevent this sort of thing, here is another: js2 mode for Emacs[1]. This is a mode originally written by Steve Yegge and then modified by some other people (be sure to get that version) that actually parses the code and, among other things, highlights global variables in a different color than local ones. I find this, along with the other things js2 does, helps prevent a whol…
Re: How One Missing `var` Ruined our Launch
#19Re: How One Missing `var` Ruined our Launch
#20Ouch. I always thought JS's global-variables-by-default schtick was it's worst crime, but I've never seen such terrible consequences for it up close before. Note to self: before products get to forbes, do some load testing. Even if I am using node, with its magic event loop of invulnerability.