Is it just me or the latest server.js file is declaring the extensionsConfig properties a bit too soon in the code ? I guess we need to wait to have all the variables it use to be declared before using them ?!

So basically we should need to cut / paste this group l.114

**
 * Define a configuration object to pass to all server extensions at
 * initialization. The extensions do not have access to this namespace,
 * so we provide them with references.
 */
var extensionsConfig = {
  'publishMessageToChannel': publishMessageToChannel,
  'publishMessageToClient': publishMessageToClient,
  'addClientToChannel': addClientToChannel,
  'settings': settings,
  'channels': channels,
  'io': io,
  'tokenChannels': tokenChannels,
  'authenticatedClients': authenticatedClients,
  'request': request,
  'sendMessageToBackend': sendMessageToBackend
};

just below the line 1095 :

invokeExtensions('setup', extensionsConfig);

So that :

**
 * Define a configuration object to pass to all server extensions at
 * initialization. The extensions do not have access to this namespace,
 * so we provide them with references.
 */
var extensionsConfig = {
  'publishMessageToChannel': publishMessageToChannel,
  'publishMessageToClient': publishMessageToClient,
  'addClientToChannel': addClientToChannel,
  'settings': settings,
  'channels': channels,
  'io': io,
  'tokenChannels': tokenChannels,
  'authenticatedClients': authenticatedClients,
  'request': request,
  'sendMessageToBackend': sendMessageToBackend
};

invokeExtensions('setup', extensionsConfig);

Cheers !

Comments

Anonymous’s picture

Version: 7.x-1.6 » 7.x-1.x-dev

oh dear, thanks for the report.

julien66’s picture

You're welcome. Thank for your work.

Can I also ask why the function publishMessageToContentChanel can not be part of this object so that I could call it directly instead of going to the backend first ?
++

trankzen’s picture

There's another problem, I'm afraid.

The invokeExtensions function is called before the io object is initialized , therefore trying to use that object in a server extension will result in a crash.

Anonymous’s picture

Status: Needs review » Fixed

i've just pushed a fix:

http://drupalcode.org/project/nodejs.git/commit/74825cae028f6ac2669eb143...

@julien66, @trankzen: please reopen if this doesn't do what you need.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

loveye0716’s picture

thank you for the report! It's working well!

  • Commit 74825ca on 7.x-1.x, 8.x-1.x, 8.x-1.x-head by beejeebus:
    #2035159: make sure we invoke extensions after all other objects are...