Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: exit server after reconfiguring #1102

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
5 changes: 1 addition & 4 deletions src/server/rollbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
32 changes: 32 additions & 0 deletions test/server.rollbar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
}
Expand Down