Flotype / now

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

Function.prototype.apply: Arguments list has wrong type #90

Closed parkotron closed 13 years ago

parkotron commented 13 years ago

I'm running a headless testing setup with phantomjs doing the rendering and sending back results via now. What I do is control phantom from node, tell is to load a url and then screenshot with timestamp on it in certain conditions and send an object with the timestamp and error so the error can be matched to the image.

I've just tried to make it more automated, so I include now into phantom, when it connects I tell it to load a page, then when it loads the page it re-injects now into phantom and does it's work.

I've started coming across this regularly though, just attempting sending strings from the client to the server:

17 May 14:25:39 - Client 41112039773724973 connected { stack: [Getter/Setter], arguments: [], type: 'apply_wrong_args', message: [Getter/Setter] } TypeError: Function.prototype.apply: Arguments list has wrong type at Function.APPLY_PREPARE (native) at Object.remoteCall (/Users/ian/local/lib/node/.npm/now/0.6.0/package/lib/nowServerLib.js:75:19) at [object Object]. (/Users/ian/local/lib/node/.npm/now/0.6.0/package/lib/nowServerLib.js:270:46) at [object Object].emit (events.js:64:17) at [object Object]._onMessage (/Users/ian/local/lib/node/.npm/socket.io/0.6.17/package/lib/socket.io/client.js:58:10) at Parser. (native) at Parser.emit (events.js:64:17) at Parser.parse (/Users/ian/local/lib/node/.npm/socket.io/0.6.17/package/lib/socket.io/transports/websocket.js:195:12) at Parser.add (/Users/ian/local/lib/node/.npm/socket.io/0.6.17/package/lib/socket.io/transports/websocket.js:182:8) at Socket. (/Users/ian/local/lib/node/.npm/socket.io/0.6.17/package/lib/socket.io/transports/websocket.js:116:17)

ericz commented 13 years ago

Interesting bug. Looking into it now

parkotron commented 13 years ago

found some time to dig myself. odd one so far,

nowServerLib.js:75:19 theFunction.apply({now: clientScope, user: client.user }, theArgs);

logging the properties there the first param object is fine, but theArgs results in:

-> site it is broken on ["hey there"] <- this is a string that looks like an array which is the problem { name: 'worker-geo-rea', sendMessage: [Function] } { clientId: '81072146166116' }

-> sites it does work on [ 'hey there' ] <- this is an array object as expected. { name: 'worker-geo-rea', sendMessage: [Function] } { clientId: '3729193222243339' }

Not sure how that argument is a string, especially as its been formatted to look like an array, there isn't a lot of client code that could cause some kind of tainting but that is my best guess so far.

ericz commented 13 years ago

I guess a quick fix would be to simply check if the theArgs variable is an array or not, and convert it to an array if not

ericz commented 13 years ago

Hi parkotron,

This should be fixed in the above commit.