-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
bugBug or defectBug or defect
Description
Check this example:
var Hapi = require('Hapi');
var server = new Hapi.Server(0);
server.route({
method: 'GET',
path: '/',
handler: function (request, reply) {
reply('Hello!');
},
config: {
pre: [
undefined // the ISSUE is here
]
}
});
server.start(function () {
console.log('Server running at:', server.info.uri);
});
server.inject('/', function (res) {
console.log(res.result);
});The output is
EDIT: note that the "server running" message is shown
Server running at: http://TomNewPC:54460
Debug: hapi, internal, implementation, error
TypeError: Uncaught error: Cannot call method 'call' of undefined
at F:\tepez\tepez-server\node_modules\Hapi\lib\handler.js:388:20
at F:\tepez\tepez-server\node_modules\Hapi\lib\handler.js:43:13
at Object.exports.parallel (F:\tepez\tepez-server\node_modules\Hapi\node_modules\items\lib\index.js:70:13)
at F:\tepez\tepez-server\node_modules\Hapi\lib\handler.js:41:15
at iterate (F:\tepez\tepez-server\node_modules\Hapi\node_modules\items\lib\index.js:35:13)
at Object.exports.serial (F:\tepez\tepez-server\node_modules\Hapi\node_modules\items\lib\index.js:38:9)
at Object.internals.prerequisites (F:\tepez\tepez-server\node_modules\Hapi\lib\handler.js:39:11)
at F:\tepez\tepez-server\node_modules\Hapi\lib\handler.js:28:23
at internals.Protect.run (F:\tepez\tepez-server\node_modules\Hapi\lib\protect.js:56:5)
at exports.execute (F:\tepez\tepez-server\node_modules\Hapi\lib\handler.js:25:22)
{ statusCode: 500,
error: 'Internal Server Error',
message: 'An internal server error occurred' }
It should have been (we get this when there is a null instead of undefined)
Error: Invalid routeConfig options (/) {
"pre": [
null
]
}
[1] pre position 0 does not match any of the allowed types
at Object.exports.assert (F:\tepez\tepez-server\node_modules\Hapi\node_modules\hoek\lib\index.js:636:11)
at Object.exports.assert (F:\tepez\tepez-server\node_modules\Hapi\lib\schema.js:15:10)
at new module.exports.internals.Route (F:\tepez\tepez-server\node_modules\Hapi\lib\route.js:47:12)
at Object.internals.add (F:\tepez\tepez-server\node_modules\Hapi\lib\router.js:83:17)
at F:\tepez\tepez-server\node_modules\Hapi\lib\router.js:75:23
at Array.forEach (native)
at Object.exports.add (F:\tepez\tepez-server\node_modules\Hapi\lib\router.js:64:24)
at internals.Connection._route (F:\tepez\tepez-server\node_modules\Hapi\lib\connection.js:283:12)
at internals.Connection.route (F:\tepez\tepez-server\node_modules\Hapi\lib\connection.js:277:10)
at Object.<anonymous> (F:\tepez\tepez-server\hapi-test.js:5:8)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugBug or defectBug or defect