Definitely you would need to develop your module with the understanding 
that it will be loaded more then once, but it should not effect 3rd party 
libraries as they would still be cached correct?

Its the only approach that I can see to solve the users scenario, another 
possible solution would be to utilize something like 
http://www.npmjs.org/package/traceback if your collecting the information 
via a function call.

Other then that the only other way I can see is to edit module.js and 
inject the actual parent into the module.  Seems kind of an odd api for the 
module when the parent isn't actually the current parent for the module. I 
can see where knowing the actual parent would be very useful, if it were 
possible to inject the current parent into the cache to make it retrievable 
could be beneficial.

On Monday, November 19, 2012 9:43:42 AM UTC-5, Bradley Meck wrote:
>
> If the module uses some form of internal storage (for caching, module 
> level object registration, etc.) it would be duplicated and then you could 
> see some interesting cache mismatch bugs.
>
> For example in the following module 2 registries would exist rather than 
> the expected one if completely reloaded:
>
> ```javascript
> var registeredHandlers = {};
> exports.register = function (event, fn) {registeredHandlers[event] = fn;}
> exports.fire = function (event) {registeredHandlers[event]();}
> ```
>
> Soo... if you setup a "prestart" function, then it gets reloaded, and 
> someone attempts to fire "prestart" on the reloaded module; it would not 
> contain the function originally registered as "prestart" and be a cache 
> mismatch, which would be very hard to debug.
>
> Don't introduce side effects into other authors' modules, so never ever do 
> this without knowing you can cause cache mismatches.
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to