strongloop / strong-mq

MQ API with cluster integration, implemented over various message queues.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

native broker can be installed multiple times, and should not be

sam-github opened this issue · comments

When multiple copies of this module exist in a dependency tree, the require is run multiple times, and this is not expected and doesn't work.

This needs to be detected and dealt with, either by working correctly (if possible), or noisily failing and explaining how to fix.

/to @bajtos Do you have suggestion for how to reproduce? Do you have an app that fails with current situation, like slnode-examples/chat? Only ways I can think of won't work well in mocha, like building a do-nothing module tree with a bunch of shell commands and count number of event listeners.

@sam-github You could probably delete the module from the cache (see this SO answer) and load it again.

Otherwise you might able to simplify the scenario you mentioned by preparing the directory structure with package.json files upfront, so that your test will only run twice npm install in different folders.

// files
sl-mq/
 test/
   multi-require-fixture/
     test.js      <-- require('foo'), require('bar')
     node_modules /
      foo/
        package.json   <-- depends on strong-mq
      bar/
        package.json   <-- depends on strong-mq

// in the test
cd multi-require-fixture/node_modules/foo && npm install
cd multi-require-fixture/node_modules/bar && npm install

Closed by #11