Skip to content

Instantly share code, notes, and snippets.

@midnightcodr
Last active November 1, 2017 16:56
server.emit is not a function
async function main() {
const Hapi = require('./lib');
const server = Hapi.server({ port: 80 });
server.event('test');
server.events.once('test', (update) => console.log(update));
await server.emit('test', 'hello');
await server.emit('test', 'hello'); // Ignored
}
main()
/* getting the following error
(node:41485) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: server.emit is not a function
(node:41485) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
*/
@midnightcodr
Copy link
Author

node --version
v8.8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment