I'm having the following error from the server once the page with the block is loaded.

Received message from client bk5hw2o2t8z1FqOAJmDh
Node JS Chat extension received a "client-message" event. Action: chat_init

/var/www/och/sites/all/modules/contrib/nodejs/nodejs_chat.module.js:19
          addClientToChannel(sessionId, message.channel);
          ^
TypeError: Property 'addClientToChannel' of object #<Object> is not a function

Comments

julien’s picture

The functions addClientToChannel, publishMessageToChannel provided as reference in server.js from nodejs are undefined in nodejs_chat.module.js. In the meantime to make it work, i had to tweak server.js and do something like this, so those functions could be use in nodejs_chat.module.js

exports.publishMessageToChannel = function (message) {
slv_’s picture

Hey Julien, thanks for the bug report, I'll look into this asap. That was certainly working fine, and there wasn't a need to call the exports.publishMessageToChannel function for that, as those functions come on the config object.

Which version of nodejs, and nodejs integration module are you using?

julien’s picture

Hello,

Version of nodejs 8.3, nodejs integration 7.2, but doing a console.log() in nodejs_chat.module.js of config variable will show that those functions are undefined.

slv_’s picture

Assigned: Unassigned » slv_

I'll try to look at this today and figure out whether there's anything to fix or not.

Thanks for the report!

slv_’s picture

Status: Active » Closed (works as designed)

Well a bit later than expected, but managed to get some time to look into this, and I can confirm this is not an issue of nodejs_chat.

The problem lives in the Node JS Integration module, since 7.x-1.1. There was a change to allow server extensions to define their own routes, but that introduced a bug by which some extensions would get very early in the server start, an incomplete config object, because some functions were defined later than the actual config object that contains them.

And that translates in the error you pointed out there, where the chat extension tries to call a function that is still not defined. This problem needs to be fixed in the nodejs integration module, and it's indeed fixed already in the dev version #2035159: extensionsConfig properties are undefined, with a commit from July 7th, so it'll be available in the next stable version, which I think should be released asap, as this is an important thing.

Closing, as "works as designed" . I'm not assigning this as a bug of nodejs module, because it's been already reported and fixed, so it'd make no sense. Will talk to beejeebus to get a new stable release published asap, so that you don't have to stick to the -dev version if you don't want to.

PS: Are you "julien66" in the issue I linked above, by any chance? ;)

julien’s picture

I did reported it when i think (you're right) the nodejs module was refactoring the extension code. I managed to solve it by recoding some stuff to make it work, but i agree it doesn't come from the nodejs_chat module.
Regarding julien66, i don't own that account.