Move emit of invalid protocol to nextTick because the handlers are not i...

Fixes #917