Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/error-reporting/src/interfaces/hapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function makeHapiPlugin(client, config) {
client.sendError(em);
}

if (isObject(reply) && isFunction(reply.continue)) {
if (reply && isFunction(reply.continue)) {
reply.continue();
}
});
Expand Down
34 changes: 25 additions & 9 deletions packages/error-reporting/test/unit/interfaces/hapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,32 @@ describe('Hapi interface', function() {
afterEach(function() {
fakeServer.removeAllListeners();
});
it('Should call continue when a boom is emitted', function(done) {
plugin.register(fakeServer, null, function() {});
fakeServer.emit(EVENT, {response: {isBoom: true}},
{
continue: function() {
// The continue function should be called
done();
it('Should call continue when a boom is emitted if reply is an object',
function(done) {
plugin.register(fakeServer, null, function() {});
fakeServer.emit(EVENT, {response: {isBoom: true}},
{
continue: function() {
// The continue function should be called
done();
}
}
}
);
);
});
it('Should call continue when a boom is emitted if reply is a function',
function(done) {
// Manually testing has shown that in actual usage the `reply` object
// provided to listeners of the `onPreResponse` event can be a function
// that has a `continue` property that is a function.
// If `reply.continue()` is not invoked in this situation, the Hapi
// app will become unresponsive.
plugin.register(fakeServer, null, function() {});
var reply = function() {};
reply.continue = function() {
// The continue function should be called
done();
};
fakeServer.emit(EVENT, {response: {isBoom: true}}, reply);
});
it('Should call sendError when a boom is received', function(done) {
var fakeClient = {
Expand Down