Flotype / now

NowJS makes it easy to build real-time web apps using JavaScript
http://www.nowjs.com
MIT License
1.92k stars 175 forks source link

Nested arrays in everyone.now cause deadlock #201

Open kylebalston opened 12 years ago

kylebalston commented 12 years ago

It's possible that I'm misunderstanding NowJS, but I get a deadlock if I execute the following code. I reproduced this using version 0.8.1 of NowJS in the helloworld_server example. It works fine if I initialize the two-dimensional array in a normal variable and then assign everyone.now.x to it.

helloworld_server.js:

var everyone = nowjs.initialize(server);
console.log("Starting...");
everyone.now.x = new Array(3);
console.log(".");
everyone.now.x[0] = new Array(3);
console.log(".");
everyone.now.x[1] = new Array(3);
console.log(".");
everyone.now.x[2] = new Array(3);
console.log("Done!");

Output is:

Starting... . .

steveWang commented 12 years ago

Preliminary debugging seems that setting an object property to an array results in unexpected behavior. Will fix later; I currently have intermittent internet access.

edit: perhaps it's only arrays initialized via the Array constructor. Behavior seems to be especially strange here: none of the properties are enumerable... until we set them manually. Huh.

I'd suggest for the time being just not using the single-integer-argument Array constructor, since that has really weird behavior (esp. in v8).