Skip to content

Throwing inside response event breaks new events #3464

@aalimovs

Description

@aalimovs

Are you sure this is an issue with hapi or are you just looking for some help?

Can reproduce in v15, v16. Can't in v14.

What are you trying to achieve or the steps to reproduce?

I've been hunting a weird production bug where hapi would stop emitting response events while still serving requests and everything else working just fine (except a growing memory footprint). I've been able to reproduce this by throwing inside a response event.

var Hapi = require('hapi');
var server = new Hapi.Server({});

server.connection({ port: 3000 });

server.start((err) => {
    if (err) { throw err }
});

server.on('response', function (request) {
    console.log('foo');
    throw 'bar';
});

What was the result you received?

In v14, sending 2 requests will result in seeing 2 console.logs and 2 errors.

In v15+, sending 2 requests will result in seeing 1 console.log and 1 error only, thus breaking any next response events from being triggered, while server carries on serving requests as normal.

What did you expect?

Expecting hapi not to silently stop emitting response events, that also affects all plugins that rely on the response event.

I assume this is related to podium introduction with v15.

Context

  • node version: 6.9.5
  • hapi version: v15, v16
  • os: Mac OS

Metadata

Metadata

Assignees

Labels

bugBug or defect

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions