diff --git a/src/server/rollbar.js b/src/server/rollbar.js index 0ce4d0570..e99b59b2e 100644 --- a/src/server/rollbar.js +++ b/src/server/rollbar.js @@ -583,9 +583,6 @@ Rollbar.prototype.setupUnhandledCapture = function () { }; Rollbar.prototype.handleUncaughtExceptions = function () { - var exitOnUncaught = !!this.options.exitOnUncaughtException; - delete this.options.exitOnUncaughtException; - addOrReplaceRollbarHandler('uncaughtException', function (err) { if (!this.options.captureUncaught && !this.options.handleUncaughtExceptions) { return; @@ -597,7 +594,7 @@ Rollbar.prototype.handleUncaughtExceptions = function () { logger.error(err); } }); - if (exitOnUncaught) { + if (this.options.exitOnUncaughtException) { setImmediate(function () { this.wait(function () { process.exit(1); diff --git a/test/server.rollbar.test.js b/test/server.rollbar.test.js index 21683be03..0e261fa56 100644 --- a/test/server.rollbar.test.js +++ b/test/server.rollbar.test.js @@ -550,6 +550,38 @@ vows.describe('rollbar') assert.equal(logStub.getCall(0).args[0].err.message, 'node error'); } notifier.log.restore(); + }, + 'exitOnUncaughtException': { + topic: function () { + var rollbar = new Rollbar({ + accessToken: 'abc123', + captureUncaught: true, + exitOnUncaughtException: true + }); + rollbar.exitStub = sinon.stub(process, 'exit'); + + nodeThrow(rollbar, this.callback); + }, + 'should exit': function (r) { + var calls = r.exitStub.getCalls(); + r.exitStub.restore(); + assert.equal(calls.length, 1); + }, + 'unrelated option reconfigured': { + topic: function(r) { + r.configure({ + environment: 'new-env' + }); + r.exitStub = sinon.stub(process, 'exit'); + + nodeThrow(r, this.callback); + }, + 'should exit': function(r) { + var calls = r.exitStub.getCalls(); + r.exitStub.restore(); + assert.equal(calls.length, 1); + } + } } } }