Faye 0.8 Cannot read property 'clientId' of undefined

343 views
Skip to first unread message

c m

unread,
Feb 28, 2012, 2:55:29 AM2/28/12
to Faye users
Hello all.

Just upgraded to 0.8 and I'm getting an error below (didn't experience
this in previous version):

2012-02-28 18:22:08 [ERROR] [Faye.NodeAdapter] Cannot read property
'clientId' of undefined
Backtrace:
TypeError: Cannot read property 'clientId' of undefined
at [object Object].onmessage (/node_modules/faye/faye-node.js:
2169:41)
at [object Object].dispatchEvent (/node_modules/faye/node_modules/
faye-websocket/lib/faye/websocket/api/event_target.js:36:29)
at [object Object].receive (/node_modules/faye/node_modules/faye-
websocket/lib/faye/websocket/api.js:30:10)
at [object Object]._emitFrame (/node_modules/faye/node_modules/
faye-websocket/lib/faye/websocket/hybi_parser.js:284:44)
at [object Object].parse (/node_modules/faye/node_modules/faye-
websocket/lib/faye/websocket/hybi_parser.js:142:18)
at Socket.<anonymous> (/node_modules/faye/node_modules/faye-
websocket/lib/faye/websocket.js:70:33)
at Socket.emit (events.js:67:17)
at TCP.onread (net.js:347:14)
Tue Feb 28 2012 18:22:10 GMT+1100 (EST) --Incoming message { channel:
'/meta/connect',
clientId: '1dislzh12731jj1w4dlua099soos',
connectionType: 'websocket',
id: 'k' }

I'm not using faye-redis. It appears to happen before a meta connect.
Faye still delivers the messages though.

James Coglan

unread,
Feb 28, 2012, 3:56:38 AM2/28/12
to faye-...@googlegroups.com
On 28 February 2012 07:55, c m <chris...@gmail.com> wrote:
Hello all.

Just upgraded to 0.8 and I'm getting an error below (didn't experience
this in previous version):

2012-02-28 18:22:08 [ERROR] [Faye.NodeAdapter] Cannot read property
'clientId' of undefined
Backtrace:
TypeError: Cannot read property 'clientId' of undefined
   at [object Object].onmessage (/node_modules/faye/faye-node.js:
2169:41)

Can you find out what the value of `event.data` is just before this line? If you can provide code to reproduce it, even better. 

c m

unread,
Feb 28, 2012, 6:06:33 AM2/28/12
to Faye users
Hello James.

The event.data doesn't appear to have any value.

event.data= []
2012-02-28 21:58:20 [ERROR] [Faye.NodeAdapter] Cannot read property
'clientId' of undefined
Backtrace:
TypeError: Cannot read property 'clientId' of undefined
at [object Object].onmessage (/node_modules/faye/faye-node.js:
2170:41)
at [object Object].dispatchEvent (/node_modules/faye/node_modules/
faye-websocket/lib/faye/websocket/api/event_target.js:36:29)
at [object Object].receive (/node_modules/faye/node_modules/faye-
websocket/lib/faye/websocket/api.js:30:10)
at [object Object]._emitFrame (/node_modules/faye/node_modules/
faye-websocket/lib/faye/websocket/hybi_parser.js:284:44)
at [object Object].parse (/node_modules/faye/node_modules/faye-
websocket/lib/faye/websocket/hybi_parser.js:142:18)
at Socket.<anonymous> (/node_modules/faye/node_modules/faye-
websocket/lib/faye/websocket.js:70:33)
at Socket.emit (events.js:67:17)
at TCP.onread (net.js:347:14)
Tue Feb 28 2012 21:59:05 GMT+1100 (EST) --Outgoing message { id: 'x',
clientId: '1kdxbdo1398umx0bmjmpi1stmde9',
channel: '/meta/connect',
successful: true,
advice: { reconnect: 'retry', interval: 0, timeout: 45000 } }
event.data= [{"channel":"/meta/
connect","clientId":"1kdxbdo1398umx0bmjmpi1stmde9","connectionType":"websocket","id":"z"}]
Tue Feb 28 2012 21:59:06 GMT+1100 (EST) --Incoming message { channel:
'/meta/connect',
clientId: '1kdxbdo1398umx0bmjmpi1stmde9',
connectionType: 'websocket',
id: 'z' }

here is app code that deals with clientId:

incoming: function(message, callback) {
...
else if (message.channel == '/meta/subscribe' && message.subscription !
= '/broadcast' && message.ext && message.ext.clientState ) {
payloads[message.clientId + ':' + message.id] = {
ucode: message.subscription.replace('/', ''),
states: message.ext.clientState
};
}
callback(message);
},
outgoing: function(message, callback) {
if (payloads[message.clientId + ':' + message.id]) {
var data = payloads[message.clientId + ':' + message.id];
// delete from temp store
delete payloads[message.clientId + ':' + message.id];

// client subscribed successfully
if (message.channel == '/meta/subscribe' && message.successful) {
// do something with data
}
}
callback(message);
}

James Coglan

unread,
Feb 28, 2012, 6:18:56 AM2/28/12
to faye-...@googlegroups.com
On 28 February 2012 11:06, c m <chris...@gmail.com> wrote:
The event.data doesn't appear to have any value.

event.data= []

Is that an array, or the string "[]". I assume it's the latter, which would indicate the client sending an empty list of messages over a WebSocket connection. This should not happen -- the WebSocket transport should not send messages over the wire in batches, so the presence of an array is suspect. Do you have any client-side extensions installed? How can I reproduce this for myself?

James Coglan

unread,
Feb 28, 2012, 3:02:08 PM2/28/12
to faye-...@googlegroups.com
On 28 February 2012 07:55, c m <chris...@gmail.com> wrote:
Just upgraded to 0.8 and I'm getting an error below (didn't experience
this in previous version):

2012-02-28 18:22:08 [ERROR] [Faye.NodeAdapter] Cannot read property
'clientId' of undefined
Backtrace:
TypeError: Cannot read property 'clientId' of undefined
   at [object Object].onmessage (/node_modules/faye/faye-node.js:
2169:41)

This should be fixed by this commit, although I'd still like to know why you're receiving "[]" over a WebSocket connection since this should never happen.

c m

unread,
Feb 29, 2012, 8:24:39 PM2/29/12
to faye-...@googlegroups.com
The client extension is just this: 
outgoing: function(message, callback) {
if (message.channel == '/meta/subscribe' && message.subscription != '/broadcast') {
if (! message.ext) message.ext = {};
message.ext.clientState = getLastMessageStates();
}
callback(message);
}

It seems to appear when I kill faye server then restart it and allow the client to connect by itself without refreshing the browser. Also, retry and ping should be set.

Thanks for the fix.

August Lilleaas

unread,
Mar 6, 2012, 4:48:01 PM3/6/12
to faye-...@googlegroups.com
I also have this issue in buster-capture-server with faye 0.8.0 from npm. Using the latest HEAD in master resolves it. Just thought I'd let you know.

August Lilleaas

unread,
Mar 6, 2012, 4:53:08 PM3/6/12
to faye-...@googlegroups.com
Whoops, it appears I tested against the wrong faye. I'm still having this issue when running the integration tests for buster-capture-server using faye HEAD in master.

James Coglan

unread,
Mar 6, 2012, 7:04:40 PM3/6/12
to faye-...@googlegroups.com
On 6 March 2012 21:53, August Lilleaas <augustl...@gmail.com> wrote:
Whoops, it appears I tested against the wrong faye. I'm still having this issue when running the integration tests for buster-capture-server using faye HEAD in master.

Can you find out why, e.g. what's the data that NodeAdapter is receiving via the socket? The commit I mentioned should have fixed this. 

August Lilleaas

unread,
Mar 7, 2012, 5:04:36 PM3/7/12
to faye-...@googlegroups.com
Will do!

August Lilleaas

unread,
Mar 9, 2012, 6:38:07 PM3/9/12
to faye-...@googlegroups.com
What's the best way to figure out this?

FYI, I'm getting this error both when using the in-process node client and a browser client.


On Wednesday, March 7, 2012 1:04:40 AM UTC+1, James Coglan wrote:

August Lilleaas

unread,
Mar 9, 2012, 6:45:48 PM3/9/12
to faye-...@googlegroups.com
Here's a dump of a test run where I add an extension to the node adapter I create that logs all activity.

I built faye by cloning the repo in master (current HEAD is 89f86255318f80c1b5542f884769368438eaa72c), running "jake" in master, and running "mv build/* ." to make the built files available for require.

Let me know if there's anything else I can do to make myself useful :)

coldcache ~/c/b/buster-capture-server % node test/buster-capture-server-test.js
The "sys" module is now called "util". It should have a similar interface.
Capture server: E
Error: Capture server attached to http server with captured slave ending session emits event
    [LOG] IN {
  channel: "/meta/handshake",
  id: "1",
  supportedConnectionTypes: ["in-process"],
  version: "1.0"
}
    [LOG] OUT {
  advice: { interval: 0, reconnect: "retry", timeout: 1000 },
  channel: "/meta/handshake",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "1",
  successful: true,
  supportedConnectionTypes: ["long-polling", "cross-origin-long-polling", "callback-polling", "websocket", "eventsource", "in-process"],
  version: "1.0"
}
    [LOG] IN {
  channel: "/meta/subscribe",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "2",
  subscription: "/capture"
}
    [LOG] OUT {
  channel: "/meta/subscribe",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "2",
  subscription: "/capture",
  successful: true
}
    [LOG] IN {
  channel: "/meta/connect",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  connectionType: "in-process",
  id: "3"
}
    [LOG] IN {
  channel: "/meta/subscribe",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "4",
  subscription: "/slaves/4d776160-826e-4d46-b6f1-413efd2f29b6/ready"
}
    [LOG] OUT {
  channel: "/meta/subscribe",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "4",
  subscription: "/slaves/4d776160-826e-4d46-b6f1-413efd2f29b6/ready",
  successful: true
}
    [LOG] IN {
  channel: "/capture",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  data: {
    becomesReadyPath: "/slaves/4d776160-826e-4d46-b6f1-413efd2f29b6/ready",
    id: "4d776160-826e-4d46-b6f1-413efd2f29b6",
    noSessionPath: "/slaves/4d776160-826e-4d46-b6f1-413efd2f29b6/no_session",
    url: "/slaves/4d776160-826e-4d46-b6f1-413efd2f29b6/browser",
    userAgent: "Mozilla/5.0 (Android; Linux armv7l; rv:10.0) Gecko/20120129 Firefox/10.0 Fennec/10.0"
  },
  id: "5"
}
    [LOG] OUT {
  channel: "/capture",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "5",
  successful: true
}
    [LOG] OUT {
  advice: { interval: 0, reconnect: "retry", timeout: 1000 },
  channel: "/meta/connect",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "3",
  successful: true
}
    [LOG] OUT {
  channel: "/capture",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  data: {
    becomesReadyPath: "/slaves/4d776160-826e-4d46-b6f1-413efd2f29b6/ready",
    id: "4d776160-826e-4d46-b6f1-413efd2f29b6",
    noSessionPath: "/slaves/4d776160-826e-4d46-b6f1-413efd2f29b6/no_session",
    url: "/slaves/4d776160-826e-4d46-b6f1-413efd2f29b6/browser",
    userAgent: "Mozilla/5.0 (Android; Linux armv7l; rv:10.0) Gecko/20120129 Firefox/10.0 Fennec/10.0"
  },
  id: "5"
}
    [LOG] IN {
  channel: "/meta/subscribe",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "6",
  subscription: "/4d776160-826e-4d46-b6f1-413efd2f29b6/session/end"
}
    [LOG] OUT {
  channel: "/meta/subscribe",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "6",
  subscription: "/4d776160-826e-4d46-b6f1-413efd2f29b6/session/end",
  successful: true
}
    [LOG] IN {
  channel: "/meta/connect",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  connectionType: "in-process",
  id: "7"
}
    [LOG] IN {
  channel: "/meta/subscribe",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "8",
  subscription: "/4d776160-826e-4d46-b6f1-413efd2f29b6/session/start"
}
    [LOG] OUT {
  channel: "/meta/subscribe",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "8",
  subscription: "/4d776160-826e-4d46-b6f1-413efd2f29b6/session/start",
  successful: true
}
    [LOG] IN {
  channel: "/slaves/4d776160-826e-4d46-b6f1-413efd2f29b6/ready",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  data: {  },
  id: "9"
}
    [LOG] OUT {
  channel: "/slaves/4d776160-826e-4d46-b6f1-413efd2f29b6/ready",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "9",
  successful: true
}
    [LOG] IN {
  channel: "/meta/subscribe",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "a",
  subscription: "/session/start"
}
    [LOG] OUT {
  channel: "/meta/subscribe",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "a",
  subscription: "/session/start",
  successful: true
}
    [LOG] IN {
  channel: "/meta/unsubscribe",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "b",
  subscription: "/capture"
}
    [LOG] OUT {
  channel: "/meta/unsubscribe",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "b",
  subscription: "/capture",
  successful: true
}
    [LOG] IN {
  channel: "/session/create",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  data: {
    session: {
      bayeuxContextPath: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838/messaging",
      id: "8b98f7f3-e221-4aba-acba-710ea7530838",
      path: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838",
      resourcesPath: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838/resources"
    }
  },
  id: "c"
}
    [LOG] OUT {
  channel: "/session/create",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "c",
  successful: true
}
    [LOG] OUT {
  advice: { interval: 0, reconnect: "retry", timeout: 1000 },
  channel: "/meta/connect",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "7",
  successful: true
}
    [LOG] OUT {
  channel: "/slaves/4d776160-826e-4d46-b6f1-413efd2f29b6/ready",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  data: {  },
  id: "9"
}
    [LOG] IN {
  channel: "/4d776160-826e-4d46-b6f1-413efd2f29b6/session/start",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  data: {
    bayeuxContextPath: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838/messaging",
    id: "8b98f7f3-e221-4aba-acba-710ea7530838",
    path: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838",
    resourcesPath: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838/resources"
  },
  id: "d"
}
    [LOG] OUT {
  channel: "/4d776160-826e-4d46-b6f1-413efd2f29b6/session/start",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "d",
  successful: true
}
    [LOG] IN {
  channel: "/meta/connect",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  connectionType: "in-process",
  id: "e"
}
    [LOG] IN {
  channel: "/meta/subscribe",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "f",
  subscription: "/4d776160-826e-4d46-b6f1-413efd2f29b6/session/8b98f7f3-e221-4aba-acba-710ea7530838/ready"
}
    [LOG] OUT {
  channel: "/meta/subscribe",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "f",
  subscription: "/4d776160-826e-4d46-b6f1-413efd2f29b6/session/8b98f7f3-e221-4aba-acba-710ea7530838/ready",
  successful: true
}
    [LOG] IN {
  channel: "/4d776160-826e-4d46-b6f1-413efd2f29b6/session/start",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  data: {
    bayeuxContextPath: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838/messaging",
    id: "8b98f7f3-e221-4aba-acba-710ea7530838",
    path: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838",
    resourcesPath: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838/resources"
  },
  id: "g"
}
    [LOG] OUT {
  channel: "/4d776160-826e-4d46-b6f1-413efd2f29b6/session/start",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "g",
  successful: true
}
    [LOG] OUT {
  advice: { interval: 0, reconnect: "retry", timeout: 1000 },
  channel: "/meta/connect",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "e",
  successful: true
}
    [LOG] OUT {
  channel: "/4d776160-826e-4d46-b6f1-413efd2f29b6/session/start",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  data: {
    bayeuxContextPath: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838/messaging",
    id: "8b98f7f3-e221-4aba-acba-710ea7530838",
    path: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838",
    resourcesPath: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838/resources"
  },
  id: "d"
}
    [LOG] OUT {
  channel: "/4d776160-826e-4d46-b6f1-413efd2f29b6/session/start",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  data: {
    bayeuxContextPath: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838/messaging",
    id: "8b98f7f3-e221-4aba-acba-710ea7530838",
    path: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838",
    resourcesPath: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838/resources"
  },
  id: "g"
}
    [LOG] IN {
  channel: "/4d776160-826e-4d46-b6f1-413efd2f29b6/session/8b98f7f3-e221-4aba-acba-710ea7530838/ready",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  data: {  },
  id: "h"
}
    [LOG] OUT {
  channel: "/4d776160-826e-4d46-b6f1-413efd2f29b6/session/8b98f7f3-e221-4aba-acba-710ea7530838/ready",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "h",
  successful: true
}
    [LOG] IN {
  channel: "/meta/connect",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  connectionType: "in-process",
  id: "i"
}
    [LOG] IN {
  channel: "/4d776160-826e-4d46-b6f1-413efd2f29b6/session/8b98f7f3-e221-4aba-acba-710ea7530838/ready",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  data: {  },
  id: "j"
}
    [LOG] OUT {
  channel: "/4d776160-826e-4d46-b6f1-413efd2f29b6/session/8b98f7f3-e221-4aba-acba-710ea7530838/ready",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "j",
  successful: true
}
    [LOG] OUT {
  advice: { interval: 0, reconnect: "retry", timeout: 1000 },
  channel: "/meta/connect",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "i",
  successful: true
}
    [LOG] OUT {
  channel: "/4d776160-826e-4d46-b6f1-413efd2f29b6/session/8b98f7f3-e221-4aba-acba-710ea7530838/ready",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  data: {  },
  id: "h"
}
    [LOG] OUT {
  channel: "/4d776160-826e-4d46-b6f1-413efd2f29b6/session/8b98f7f3-e221-4aba-acba-710ea7530838/ready",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  data: {  },
  id: "j"
}
    [LOG] IN {
  channel: "/session/start",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  data: {
    session: {
      bayeuxContextPath: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838/messaging",
      id: "8b98f7f3-e221-4aba-acba-710ea7530838",
      path: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838",
      resourcesPath: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838/resources"
    },
    slaves: [{
  id: "4d776160-826e-4d46-b6f1-413efd2f29b6",
  userAgent: "Mozilla/5.0 (Android; Linux armv7l; rv:10.0) Gecko/20120129 Firefox/10.0 Fennec/10.0"
}]
  },
  id: "k"
}
    [LOG] OUT {
  channel: "/session/start",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "k",
  successful: true
}
    [LOG] IN {
  channel: "/meta/connect",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  connectionType: "in-process",
  id: "l"
}
    [LOG] OUT {
  advice: { interval: 0, reconnect: "retry", timeout: 1000 },
  channel: "/meta/connect",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "l",
  successful: true
}
    [LOG] OUT {
  channel: "/session/start",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  data: {
    session: {
      bayeuxContextPath: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838/messaging",
      id: "8b98f7f3-e221-4aba-acba-710ea7530838",
      path: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838",
      resourcesPath: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838/resources"
    },
    slaves: [{
  id: "4d776160-826e-4d46-b6f1-413efd2f29b6",
  userAgent: "Mozilla/5.0 (Android; Linux armv7l; rv:10.0) Gecko/20120129 Firefox/10.0 Fennec/10.0"
}]
  },
  id: "k"
}
    [LOG] IN {
  channel: "/meta/subscribe",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "m",
  subscription: "/session/end"
}
    [LOG] OUT {
  channel: "/meta/subscribe",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "m",
  subscription: "/session/end",
  successful: true
}
    [LOG] IN {
  channel: "/meta/connect",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  connectionType: "in-process",
  id: "n"
}
    [LOG] IN {
  channel: "/session/end",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  data: {
    session: {
      bayeuxContextPath: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838/messaging",
      id: "8b98f7f3-e221-4aba-acba-710ea7530838",
      path: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838",
      resourcesPath: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838/resources"
    }
  },
  id: "o"
}
    [LOG] OUT {
  channel: "/session/end",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "o",
  successful: true
}
    [LOG] IN {
  channel: "/meta/unsubscribe",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "p",
  subscription: "/session/start"
}
    [LOG] OUT {
  channel: "/meta/unsubscribe",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "p",
  subscription: "/session/start",
  successful: true
}
    [LOG] OUT {
  advice: { interval: 0, reconnect: "retry", timeout: 1000 },
  channel: "/meta/connect",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  id: "n",
  successful: true
}
    [LOG] OUT {
  channel: "/session/end",
  clientId: "1bu7zyd1m17ysb0puos8c0q7s8in",
  data: {
    session: {
      bayeuxContextPath: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838/messaging",
      id: "8b98f7f3-e221-4aba-acba-710ea7530838",
      path: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838",
      resourcesPath: "/sessions/8b98f7f3-e221-4aba-acba-710ea7530838/resources"
    }
  },
  id: "o"
}

    TypeError: Cannot read property '0' of undefined
    at Object.trigger (/home/augustl/code/buster/faye/faye-node.js:379:15)
    at Object.distributeMessage (/home/augustl/code/buster/faye/faye-node.js:663:30)
    at Object._deliverMessage (/home/augustl/code/buster/faye/faye-node.js:1065:20)
    at Object.<anonymous> (/home/augustl/code/buster/faye/faye-node.js:1004:12)
    at /home/augustl/code/buster/faye/faye-node.js:532:39
    at Object.incoming (./lib/slave.js:213:13)
    at /home/augustl/code/buster/faye/faye-node.js:534:44
    at Object.pipeThroughExtensions (/home/augustl/code/buster/faye/faye-node.js:537:5)
    at Object.receiveMessage (/home/augustl/code/buster/faye/faye-node.js:1000:10)
    at Object.receive (/home/augustl/code/buster/faye/faye-node.js:1135:20)



On Wednesday, March 7, 2012 1:04:40 AM UTC+1, James Coglan wrote:

August Lilleaas

unread,
Mar 9, 2012, 6:49:08 PM3/9/12
to faye-...@googlegroups.com
..and one more thing. Line 213 of slave.js is this:

    bayeuxClient.addExtension({
        incoming: function (message, callback) {
            if (message.channel == becomesReadyPath) {
                slave.ready = true;
                bayeuxClientId = message.clientId;
                broadcastSession();
            }

            callback(message);
        }
    });

The 3rd last line is line 213. `bayeuxClient` is a reference to myNodeAdapter.getClient().

August Lilleaas

unread,
Mar 12, 2012, 10:28:43 AM3/12/12
to faye-...@googlegroups.com
Let me know if you need anything else :)

James Coglan

unread,
Mar 12, 2012, 1:19:32 PM3/12/12
to faye-...@googlegroups.com
On 9 March 2012 23:45, August Lilleaas <augustl...@gmail.com> wrote:
    TypeError: Cannot read property '0' of undefined
    at Object.trigger (/home/augustl/code/buster/faye/faye-node.js:379:15)
    at Object.distributeMessage (/home/augustl/code/buster/faye/faye-node.js:663:30)
    at Object._deliverMessage (/home/augustl/code/buster/faye/faye-node.js:1065:20)
    at Object.<anonymous> (/home/augustl/code/buster/faye/faye-node.js:1004:12)
    at /home/augustl/code/buster/faye/faye-node.js:532:39
    at Object.incoming (./lib/slave.js:213:13)
    at /home/augustl/code/buster/faye/faye-node.js:534:44
    at Object.pipeThroughExtensions (/home/augustl/code/buster/faye/faye-node.js:537:5)
    at Object.receiveMessage (/home/augustl/code/buster/faye/faye-node.js:1000:10)
    at Object.receive (/home/augustl/code/buster/faye/faye-node.js:1135:20)

That error is coming from somewhere else, not the WebSocket stuff. This is the offending method:

  trigger: function() {
    var args = Array.prototype.slice.call(arguments),
        eventType = args.shift();
    
    if (!this._subscribers || !this._subscribers[eventType]) return;
    
    var listeners = this._subscribers[eventType],
        listener;
    
    for (var i = 0, n = listeners.length; i < n; i++) {
      listener = listeners[i];
      listener[0].apply(listener[1], args); // <-- this line throws the error
    }
  } 

This happens because listeners[i] is undefined, meaning we have a sparse array problem (e.g. list not being correctly updated on unsubscribe), or that a listener is removed during the loop. This is happening on the client side when Faye distributes messages to your callback functions. Do this help explain why you're seeing the error?

One thing worth noting is that in Faye 0.8 I stopped using Faye.each() -- a forEach-alike -- and just used literal for-loops most places. I'm wondering if this introduced some holes. e.g. this loop is obviously not mutation-safe, but I don't know if it needs to be -- you might need to dig in buster a bit more to figure out what's going on.

August Lilleaas

unread,
Mar 12, 2012, 7:38:24 PM3/12/12
to faye-...@googlegroups.com
When I think about it, the only thing that can cause this error is unsubscribing in an event handler, since we're running in a single threaded environment.  And it turns out I am doing some unsubsubscribing in event listeners.

So I guess I can lean back and wait for a fix? :)

FYI, this is a short example of what I do. I unsubscribe from the handler in order to perform a "subscribe once" type operation.

function handler () {
    // Do stuff ....
    faye.unsubscribe("/foo", handler);
}
faye.subscribe("/foo", handler);

James Coglan

unread,
Mar 14, 2012, 7:11:27 PM3/14/12
to faye-...@googlegroups.com
On 12 March 2012 23:38, August Lilleaas <augustl...@gmail.com> wrote:
When I think about it, the only thing that can cause this error is unsubscribing in an event handler, since we're running in a single threaded environment.  And it turns out I am doing some unsubsubscribing in event listeners.

So I guess I can lean back and wait for a fix? :)

FYI, this is a short example of what I do. I unsubscribe from the handler in order to perform a "subscribe once" type operation.

function handler () {
    // Do stuff ....
    faye.unsubscribe("/foo", handler);
}
faye.subscribe("/foo", handler);

This is fixed in https://github.com/faye/faye/commit/6ed56af61540a92d6ca5ebc2c72a09a0ea34e73f. The behaviour is now that all the event listeners registered at the time the trigger() call is made will be run. So e.g., if callback A unbinds callback B, callback B will still run on that trigger() call but not on the next one. Make sense?

August Lilleaas

unread,
Mar 15, 2012, 4:58:44 AM3/15/12
to faye-...@googlegroups.com
Sounds like a good solution for most/all cases. And the tests are passing with faye master now, so it certainly solved the issue.

Did you do something to improve performance in 0.8? For some reason my phantomjs integration tests run a hell of a lot faster now, and I don't think I've changed anything besides upgrading from faye 0.7 to 0.8.

James Coglan

unread,
Mar 15, 2012, 5:56:08 AM3/15/12
to faye-...@googlegroups.com
On 15 March 2012 08:58, August Lilleaas <augustl...@gmail.com> wrote:
Did you do something to improve performance in 0.8? For some reason my phantomjs integration tests run a hell of a lot faster now, and I don't think I've changed anything besides upgrading from faye 0.7 to 0.8.

Yeah, a few things. e.g. immediate push over WebSocket rather than waiting for /meta/connect poll, replacing forEach() with for, improving speed of copyObject(). Is it using WebSocket on Phantom? If not, could be introduction of EventSource where previously Phantom used XHR. 

James Coglan

unread,
Mar 15, 2012, 6:16:04 AM3/15/12
to faye-...@googlegroups.com
Oh and there's a big perf improvements in faye-websocket since it was extracted: http://blog.jcoglan.com/2011/12/21/faye-websocket-0-2-big-performance-boost-and-subprotocol-support/ 
Reply all
Reply to author
Forward
0 new messages