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

TypeError: Cannot call method 'apply' of undefined in now/lib/user.js #171

Open mikl opened 12 years ago

mikl commented 12 years ago

I encountered this traceback in our logs today, just after a restart of the Now.js server. The remarkable part is that the traceback is entirely between Now.js and Socket.io, i.e., it would seem that our own code is not the cause:

[TypeError: Cannot call method 'apply' of undefined]
TypeError: Cannot call method 'apply' of undefined
  at Socket.rfcHandler (/srv/www/drupal7/profiles/lektier/spravka/node_modules/now/lib/user.js:101:19)
  at Socket.$emit (events.js:67:17)
  at SocketNamespace.handlePacket (/srv/www/drupal7/profiles/lektier/spravka/node_modules/now/node_modules/socket.io/lib/namespace.js:335:22)
  at Manager.onClientMessage (/srv/www/drupal7/profiles/lektier/spravka/node_modules/now/node_modules/socket.io/lib/manager.js:462:38)
  at WebSocket.onMessage (/srv/www/drupal7/profiles/lektier/spravka/node_modules/now/node_modules/socket.io/lib/transport.js:387:20)
  at Parser.<anonymous> (/srv/www/drupal7/profiles/lektier/spravka/node_modules/now/node_modules/socket.io/lib/transports/websocket/hybi-16.js:40:10)
  at Parser.emit (events.js:67:17)
  at /srv/www/drupal7/profiles/lektier/spravka/node_modules/now/node_modules/socket.io/lib/transports/websocket/hybi-16.js:289:16
  at Parser.expectHandler (/srv/www/drupal7/profiles/lektier/spravka/node_modules/now/node_modules/socket.io/lib/transports/websocket/hybi-16.js:300:15)
  at Parser.add (/srv/www/drupal7/profiles/lektier/spravka/node_modules/now/node_modules/socket.io/lib/transports/websocket/hybi-16.js:467:24)
mikl commented 12 years ago

It also occurred later without a restart of the server, so there's something strange going on. It could ostensibly be worked around by checking theFunction before call()'ing it.

These are the versions I'm using:

├─┬ now@0.7.6 
│ ├── node-proxy@0.5.2 
│ └─┬ socket.io@0.8.7 
│   ├── policyfile@0.0.4 
│   ├── redis@0.6.7 
│   └─┬ socket.io-client@0.8.7 
│     ├── uglify-js@1.0.6 
│     ├── websocket-client@1.0.0 
│     └── xmlhttprequest@1.2.2 
Peterfly commented 12 years ago

True. this error may occur when you emit a remote function call on a fqn whose function is undefined. please check the branch removegroup(./lib/user.js) from line 110. Is it what you suggested?

steveWang commented 12 years ago

This still doesn't resolve the fundamental issue: why are remote function calls being requested for undefined functions? I imagine no manual injections are at work, so an initial guess would be a closure call. If you can figure out how to replicate the error, I'd appreciate it if you could turn up log level to 3 and provide some more detailed output.