{"action":"created","issue":{"url":"https://api.github.com/repos/hapijs/hapi/issues/3150","repository_url":"https://api.github.com/repos/hapijs/hapi","labels_url":"https://api.github.com/repos/hapijs/hapi/issues/3150/labels{/name}","comments_url":"https://api.github.com/repos/hapijs/hapi/issues/3150/comments","events_url":"https://api.github.com/repos/hapijs/hapi/issues/3150/events","html_url":"https://github.com/hapijs/hapi/issues/3150","id":154682422,"number":3150,"title":"server.method doesn't resolve promise with cache options","user":{"login":"tsm91","id":4459551,"avatar_url":"https://avatars.githubusercontent.com/u/4459551?v=3","gravatar_id":"","url":"https://api.github.com/users/tsm91","html_url":"https://github.com/tsm91","followers_url":"https://api.github.com/users/tsm91/followers","following_url":"https://api.github.com/users/tsm91/following{/other_user}","gists_url":"https://api.github.com/users/tsm91/gists{/gist_id}","starred_url":"https://api.github.com/users/tsm91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tsm91/subscriptions","organizations_url":"https://api.github.com/users/tsm91/orgs","repos_url":"https://api.github.com/users/tsm91/repos","events_url":"https://api.github.com/users/tsm91/events{/privacy}","received_events_url":"https://api.github.com/users/tsm91/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hapijs/hapi/labels/bug","name":"bug","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-05-13T10:33:35Z","updated_at":"2016-06-10T14:36:10Z","closed_at":null,"body":"You register a server method and that method returns a promise **and** specify caching options as the 3rd argument. The thing dies.\r\n\r\n```js\r\nserver.method('test', function () {\r\n  return Promise.resolve('works');\r\n}, {\r\n  // if you remove the cache options it works as expected\r\n  cache: {\r\n    cache: 'redisCache',\r\n    expiresIn: 30 * 1000,\r\n    generateTimeout: 100\r\n  }\r\n});\r\n```\r\n\r\nIf you omit the `cache` options everything runs great.\r\n\r\nHere is a working [gist](https://gist.github.com/tsm91/4cec4cc16048cd3458b17cc3cce5b84a) how to reproduce.\r\n\r\nTested on node `v6.1.0`, `v4.3.0`.\r\n\r\nstack trace:\r\n```sh\r\nDebug: internal, implementation, error\r\n    TypeError: Uncaught error: Cannot read property 'then' of undefined\r\n    at server.route.handler (/Users/tsm/Sites/__projects/hapi-api/reproduce.js:36:7)\r\n    at Object.exports.execute.internals.prerequisites.internals.handler.callback [as handler] (/Users/tsm/Sites/__projects/hapi-api/node_modules/hapi/lib/handler.js:96:36)\r\n    at /Users/tsm/Sites/__projects/hapi-api/node_modules/hapi/lib/handler.js:30:23\r\n    at internals.Protect.run.finish [as run] (/Users/tsm/Sites/__projects/hapi-api/node_modules/hapi/lib/protect.js:64:5)\r\n    at exports.execute.finalize (/Users/tsm/Sites/__projects/hapi-api/node_modules/hapi/lib/handler.js:24:22)\r\n    at each (/Users/tsm/Sites/__projects/hapi-api/node_modules/hapi/lib/request.js:383:16)\r\n    at iterate (/Users/tsm/Sites/__projects/hapi-api/node_modules/hapi/node_modules/items/lib/index.js:36:13)\r\n    at done (/Users/tsm/Sites/__projects/hapi-api/node_modules/hapi/node_modules/items/lib/index.js:28:25)\r\n    at internals.Auth.test.internals.Auth._authenticate (/Users/tsm/Sites/__projects/hapi-api/node_modules/hapi/lib/auth.js:210:16)\r\n    at internals.Auth.test.internals.Auth.authenticate (/Users/tsm/Sites/__projects/hapi-api/node_modules/hapi/lib/auth.js:202:17)\r\nDebug: internal, implementation, error\r\n    TypeError: Cannot read property 'apply' of undefined\r\n    at /Users/tsm/Sites/__projects/hapi-api/node_modules/hapi/node_modules/catbox/node_modules/hoek/lib/index.js:850:21\r\n    at nextTickCallbackWith0Args (node.js:453:9)\r\n    at process._tickDomainCallback (node.js:423:13)\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/hapijs/hapi/issues/comments/225199373","html_url":"https://github.com/hapijs/hapi/issues/3150#issuecomment-225199373","issue_url":"https://api.github.com/repos/hapijs/hapi/issues/3150","id":225199373,"user":{"login":"nlf","id":424045,"avatar_url":"https://avatars.githubusercontent.com/u/424045?v=3","gravatar_id":"","url":"https://api.github.com/users/nlf","html_url":"https://github.com/nlf","followers_url":"https://api.github.com/users/nlf/followers","following_url":"https://api.github.com/users/nlf/following{/other_user}","gists_url":"https://api.github.com/users/nlf/gists{/gist_id}","starred_url":"https://api.github.com/users/nlf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nlf/subscriptions","organizations_url":"https://api.github.com/users/nlf/orgs","repos_url":"https://api.github.com/users/nlf/repos","events_url":"https://api.github.com/users/nlf/events{/privacy}","received_events_url":"https://api.github.com/users/nlf/received_events","type":"User","site_admin":false},"created_at":"2016-06-10T14:36:10Z","updated_at":"2016-06-10T14:36:10Z","body":"or we could make a breaking change and resolve the promise with an object, or an array (value is the first item, ttl the second), or expose it some other way. there's a lot we can do to make this work in a more consistent manner."}}
{"actor":{"display_login":"nlf"}}