rollbar 2.24.0 → 2.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -491,6 +491,37 @@ function wrapCallback(logger, f) {
491
491
  };
492
492
  }
493
493
 
494
+ function nonCircularClone(obj) {
495
+ var seen = [obj];
496
+
497
+ function clone(obj, seen) {
498
+ var value, name, newSeen, result = {};
499
+
500
+ try {
501
+ for (name in obj) {
502
+ value = obj[name];
503
+
504
+ if (value && (isType(value, 'object') || isType(value, 'array'))) {
505
+ if (seen.includes(value)) {
506
+ result[name] = 'Removed circular reference: ' + typeName(value);
507
+ } else {
508
+ newSeen = seen.slice();
509
+ newSeen.push(value);
510
+ result[name] = clone(value, newSeen);
511
+ }
512
+ continue;
513
+ }
514
+
515
+ result[name] = value;
516
+ }
517
+ } catch (e) {
518
+ result = 'Failed cloning custom data: ' + e.message;
519
+ }
520
+ return result;
521
+ }
522
+ return clone(obj, seen);
523
+ }
524
+
494
525
  function createItem(args, logger, notifier, requestKeys, lambdaContext) {
495
526
  var message, err, custom, callback, request;
496
527
  var arg;
@@ -548,10 +579,12 @@ function createItem(args, logger, notifier, requestKeys, lambdaContext) {
548
579
  }
549
580
  }
550
581
 
582
+ // if custom is an array this turns it into an object with integer keys
583
+ if (custom) custom = nonCircularClone(custom);
584
+
551
585
  if (extraArgs.length > 0) {
552
- // if custom is an array this turns it into an object with integer keys
553
- custom = merge(custom);
554
- custom.extraArgs = extraArgs;
586
+ if (!custom) custom = nonCircularClone({});
587
+ custom.extraArgs = nonCircularClone(extraArgs);
555
588
  }
556
589
 
557
590
  var item = {
@@ -596,7 +629,7 @@ function addErrorContext(item, errors) {
596
629
  try {
597
630
  for (var i = 0; i < errors.length; ++i) {
598
631
  if (errors[i].hasOwnProperty('rollbarContext')) {
599
- custom = merge(custom, errors[i].rollbarContext);
632
+ custom = merge(custom, nonCircularClone(errors[i].rollbarContext));
600
633
  contextAdded = true;
601
634
  }
602
635
  }
@@ -4553,7 +4586,7 @@ module.exports = {
4553
4586
 
4554
4587
 
4555
4588
  module.exports = {
4556
- version: '2.24.0',
4589
+ version: '2.24.1',
4557
4590
  endpoint: 'api.rollbar.com/api/1/item/',
4558
4591
  logLevel: 'debug',
4559
4592
  reportLevel: 'debug',