senecajs / seneca

A microservices toolkit for Node.js.
http://senecajs.org
MIT License
3.95k stars 314 forks source link

Shared object not available in preload function #899

Open vitorclelis96 opened 2 years ago

vitorclelis96 commented 2 years ago

In the preload function, the shared object ins't created yet. Example:

async function preload(seneca) {
  // seneca.shared is null
  seneca.shared = {}; // Need to manually boot seneca shared

  // Now you can use the seneca.shared instance here
  seneca.shared.x = 10;
  // shared.x will be available outside
}

Fix: Instead of manually creating seneca.shared = {}, the seneca instance should be available already in preload function.