Skip to content

Instantly share code, notes, and snippets.

@aegyed91
Created May 13, 2016 10:16
Show Gist options
  • Save aegyed91/4cec4cc16048cd3458b17cc3cce5b84a to your computer and use it in GitHub Desktop.
Save aegyed91/4cec4cc16048cd3458b17cc3cce5b84a to your computer and use it in GitHub Desktop.
hapi server method promise bug reproduction
var Hapi = require('hapi');
const server = new Hapi.Server({
cache: [
{
name: 'redisCache',
engine: require('catbox-redis'),
host: '127.0.0.1',
partition: 'cache'
}
]
});
server.connection({
port: 8000
});
server.method('test', function () {
return Promise.resolve('works');
}, {
// if you remove the cache options it works as expected
cache: {
cache: 'redisCache',
expiresIn: 30 * 1000,
generateTimeout: 100
}
});
server.route({
path: '/test',
method: 'GET',
handler: function (request, reply) {
server.methods
.test()
.then(function (msg) {
reply(msg);
})
.catch(function (err) {
reply(err);
});
}
});
server
.start()
.then(function() {
console.log('check localhost:8000/test');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment