Skip to content

Commit

Permalink
Fix exception handler config to use ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Loring committed Apr 19, 2016
1 parent 751807a commit 77f1c19
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/trace-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ function TraceAgent(config, logger) {

this.policy = tracingPolicy.createTracePolicy(config);

if (config.onUncaughtException !== 'disregard') {
console.log(config.onUncaughtException);

This comment has been minimized.

Copy link
@AdriVanHoudt

AdriVanHoudt Apr 19, 2016

Contributor

should this be here?

This comment has been minimized.

Copy link
@matthewloring

matthewloring Apr 19, 2016

Contributor

It should not. Good catch!

This comment has been minimized.

Copy link
@AdriVanHoudt

AdriVanHoudt Apr 19, 2016

Contributor

No problem!

if (config.onUncaughtException !== 'ignore') {
this.unhandledException = function() {
traceAgent.traceWriter.flushBuffer_(traceAgent.config_.projectId);
if (config.onUncaughtException === 'flushAndExit') {
Expand All @@ -67,7 +68,7 @@ TraceAgent.prototype.stop = function() {
this.traceWriter.stop();
this.namespace = null;
traceAgent = null;
if (this.config_.onUncaughtException !== 'disregard') {
if (this.config_.onUncaughtException !== 'ignore') {
process.removeListener('uncaughtException', this.unhandledException);
}
this.logger.info('trace agent deactivated');
Expand Down
7 changes: 7 additions & 0 deletions test/standalone/test-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ describe('index.js', function() {
wrapTest(require('module'), '_load');
});

it('should not attach exception handler with ignore option', function() {
agent.start();
// Mocha attaches 1 exception handler
assert.equal(process.listeners('uncaughtException').length, 1);
agent.stop();
});

it('should wrap/unwrap http on start/stop', function() {
agent.start(); // agent needs to be started before the first require.
var http = require('http');
Expand Down

0 comments on commit 77f1c19

Please sign in to comment.