hapijs / glue

Server composer for hapi.js
Other
245 stars 62 forks source link

Error: Cannot start server before plugins finished registration #117

Closed utkj97 closed 6 years ago

utkj97 commented 6 years ago

I am using glue to create a server in Hapi. It gives me an error as follows:

Error: Cannot start the server before plugins finished the registration
    at module.exports.internals.Core._initialize (/home/Utkarsh_Jaiswal/Documents/X/Production/X/node_modules/hapi/lib/core.js:306:19)
    at module.exports.internals.Core._start (/home/Utkarsh_Jaiswal/Documents/X/Production/X/node_modules/hapi/lib/core.js:237:24)
    at internals.Server.start (/home/Utkarsh_Jaiswal/Documents/X/Production/X/node_modules/hapi/lib/server.js:509:27)
    at startServer (/home/Utkarsh_Jaiswal/Documents/X/Production/X/index.js:28:20)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:721:11)
    at startup (internal/bootstrap/node.js:228:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:576:3)

I am using the same code as given in the documentation to configure the server:

const startServer = async function () {
  try {
      const server = await Glue.compose(Manifest.get('/'), composeOptions);
      await server.start();
      console.log('hapi days!');
  }
  catch (err) {
      console.error(err);
      process.exit(1);
  }
};

startServer();

I am using some custom plugins which are working just fine but server.start() is being executed before their registration. await does not seem to work. What can be the possible reason?

Node version: v10.1.0
Hapi version: 17.5.1
Glue version: 5.0.0
I am using confidence package as well:
version: 3.0.2
WesTyler commented 6 years ago

Any chance you could include your manifest? It's hard to help debug without being able to see the manifest and plugins.

Also double check the control flow on the registration method on any custom plugins you are registering.

csrl commented 6 years ago

The error comes from hapi when plugins are still in the 'registering' state. Apparently you are loading a plugin that is not properly implemented.

I'd suggest including 1 plugin at a time to isolate which one(s) are causing your issue.

WesTyler commented 6 years ago

It's been a month with no updates here. I'm going to close this since it has stagnated and there doesn't appear to be any actionable tasks for maintainers.

Feel free to shout at me if you want me to reopen.

lock[bot] commented 4 years ago

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.