Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start server without callback fails #2705

Closed
felansu opened this issue Aug 12, 2015 · 6 comments
Closed

Start server without callback fails #2705

felansu opened this issue Aug 12, 2015 · 6 comments
Labels
documentation Non-code related changes non issue Issue is not a problem or requires changes

Comments

@felansu
Copy link

felansu commented Aug 12, 2015

When starts the server without callback as it described at example on home page

Code example

var Hapi = require('hapi');

// Create a server with a host and port
var server = new Hapi.Server();
server.connection({ 
    host: 'localhost', 
    port: 8000 
});

// Add the route
server.route({
    method: 'GET',
    path:'/hello', 
    handler: function (request, reply) {
       reply('hello world');
    }
});

// Start the server
server.start();

Exception

/home/felansu/Projects/QRBWEB/node_modules/hapi/lib/server.js:242
        return callback();
               ^
TypeError: undefined is not a function
    at /home/felansu/Projects/QRBWEB/node_modules/hapi/lib/server.js:242:16
    at /home/felansu/Projects/QRBWEB/node_modules/hapi/node_modules/hoek/lib/index.js:841:22
    at process._tickDomainCallback (node.js:381:11)

Version report

└─┬ hapi@9.0.1
  ├── accept@1.1.0
  ├── ammo@1.0.1
  ├── boom@2.8.0
  ├── call@2.0.2
  ├── catbox@6.0.0
  ├── catbox-memory@1.1.1
  ├── cryptiles@2.0.4
  ├─┬ heavy@3.0.0
  │ └─┬ joi@5.1.0
  │   ├── isemail@1.1.1
  │   └── moment@2.10.6
  ├── hoek@2.14.0
  ├── iron@2.1.3
  ├── items@1.1.0
  ├─┬ joi@6.6.1
  │ ├── isemail@1.1.1
  │ └── moment@2.10.6
  ├── kilt@1.1.1
  ├─┬ mimos@2.0.2
  │ └── mime-db@1.16.0
  ├── peekaboo@1.0.0
  ├── qs@4.0.0
  ├── shot@1.6.0
  ├── statehood@2.1.1
  ├─┬ subtext@2.0.0
  │ ├── content@1.0.2
  │ ├─┬ pez@1.0.0
  │ │ ├── b64@2.0.0
  │ │ └─┬ nigel@1.0.1
  │ │   └── vise@1.0.0
  │ └── wreck@6.1.0
  └── topo@1.0.3
@cleydsonjr
Copy link

+1

@mtharrison
Copy link
Contributor

This is a new requirement in hapi 9. See release notes here: #2682

@mtharrison mtharrison added the non issue Issue is not a problem or requires changes label Aug 12, 2015
@felansu
Copy link
Author

felansu commented Aug 12, 2015

I've seen the message: "Require callback for server.start() and server.stop()."

Then I think the problem is that the code example on the hapi homepage is wrong. Also as it is required hapi could throw a better message validating whether callback is defined.

Thanks

@mtharrison mtharrison added the documentation Non-code related changes label Aug 12, 2015
@lloydbenson
Copy link
Contributor

The site is fixed code wise but it looks like it needs to be redeployed again.

@lloydbenson
Copy link
Contributor

outmoded/hapijs.com#228

This is a hapijs.com issue not hapi specifically. I have linked the issue here for reference. Please close this. I have issued a PR for review.

@felansu felansu closed this as completed Aug 12, 2015
@monkeytroy
Copy link

+1 for felansu comment. Better error message would be great on this.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Non-code related changes non issue Issue is not a problem or requires changes
Projects
None yet
Development

No branches or pull requests

5 participants