Skip to content

Commit

Permalink
Merge pull request #508 from jimmyroostermoney/master
Browse files Browse the repository at this point in the history
Initialise empty exceptions array to fix unshift undefined error
  • Loading branch information
carolabadeer authored May 18, 2022
2 parents 0124e92 + c465e93 commit 16c96c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/core/lib/segments/attributes/subsegment.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Subsegment.prototype.addError = function addError(err, remote) {
if (this.segment && this.segment.exception) {
if (err === this.segment.exception.ex) {
this.fault = true;
this.cause = { id: this.segment.exception.cause };
this.cause = { id: this.segment.exception.cause, exceptions: [] };
return;
}
delete this.segment.exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ describe('Subsegment', function() {
subsegment.addError(err, true);
exceptionStub.should.have.been.calledWithExactly(err, true);
});
it('should initialise exceptions if matching errors are passed consecutively', function () {
subsegment.segment = { trace_id: '1-58c835af-cf6bfe9f8f2c5b84a6d1f50c', parent_id: '12345abc3456def' };
subsegment.addError(err);
subsegment.addError(err);
assert.equal(subsegment.cause.exceptions.length, 0);
assert.notEqual(subsegment.cause.exceptions, undefined);
});
});

describe('#incrementCounter', function() {
Expand Down

0 comments on commit 16c96c5

Please sign in to comment.