Socket.io: CreateListFromArrayLike called on non-object

Created on 18 Dec 2017  路  5Comments  路  Source: socketio/socket.io

You want to:

  • [x] report a bug
  • [ ] request a feature

Current behaviour

Server dies instantly, cause unknown

Steps to reproduce (if the current behaviour is a bug)

This happened passively, I found this in my error log

/home/ubuntu/node_modules/socket.io/lib/socket.js:503
      emit.apply(self, event);
           ^

TypeError: CreateListFromArrayLike called on non-object
    at /home/ubuntu/node_modules/socket.io/lib/socket.js:503:12
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)

Expected behaviour

Handle the issue, provide more information

Setup

  • OS: Ubuntu
  • browser: Node 7.7.1
  • socket.io version: 1.7.3

Other information (e.g. stacktraces, related issues, suggestions how to fix)

Most helpful comment

I had this issue on a fairly high load server. Was getting a lot of uncaught exceptions. The way I fixed it was to add this line to /node_modules/socket.io/lib/socket.js

if (typeof event !== 'object') return false;

Above line 513, emit.apply(self, event);

This seems to have fixed the issue for now but not sure if it's a good permanent solution.

All 5 comments

I have been seeing a bunch of these errors as well

apply expects event to be a type of array, if event is of any other data type, apply will throw the TypeError. My guess is that event is somewhat null or undefined in this case, probably because decoding data failed and the packet.data is in ill form. Anyway, we should probably check if event is an array before calling apply with it as 2nd argument.

I will submit a PR to put a safeguard in place.

I had this issue on a fairly high load server. Was getting a lot of uncaught exceptions. The way I fixed it was to add this line to /node_modules/socket.io/lib/socket.js

if (typeof event !== 'object') return false;

Above line 513, emit.apply(self, event);

This seems to have fixed the issue for now but not sure if it's a good permanent solution.

I'm also experiencing the same issue..

Same issue here, after a migration of my projets to a new workstation, and trying to launch my gulp tasks over a fresh node.js & npm packages installation. I tried other solutions, downgrading node.js to my last machine version, erasing & reinstall of node modules, but only jamesbachini solution works for me

Was this page helpful?
0 / 5 - 0 ratings