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.
@@ -501,6 +501,37 @@ function wrapCallback(logger, f) {
501
501
  };
502
502
  }
503
503
 
504
+ function nonCircularClone(obj) {
505
+ var seen = [obj];
506
+
507
+ function clone(obj, seen) {
508
+ var value, name, newSeen, result = {};
509
+
510
+ try {
511
+ for (name in obj) {
512
+ value = obj[name];
513
+
514
+ if (value && (isType(value, 'object') || isType(value, 'array'))) {
515
+ if (seen.includes(value)) {
516
+ result[name] = 'Removed circular reference: ' + typeName(value);
517
+ } else {
518
+ newSeen = seen.slice();
519
+ newSeen.push(value);
520
+ result[name] = clone(value, newSeen);
521
+ }
522
+ continue;
523
+ }
524
+
525
+ result[name] = value;
526
+ }
527
+ } catch (e) {
528
+ result = 'Failed cloning custom data: ' + e.message;
529
+ }
530
+ return result;
531
+ }
532
+ return clone(obj, seen);
533
+ }
534
+
504
535
  function createItem(args, logger, notifier, requestKeys, lambdaContext) {
505
536
  var message, err, custom, callback, request;
506
537
  var arg;
@@ -558,10 +589,12 @@ function createItem(args, logger, notifier, requestKeys, lambdaContext) {
558
589
  }
559
590
  }
560
591
 
592
+ // if custom is an array this turns it into an object with integer keys
593
+ if (custom) custom = nonCircularClone(custom);
594
+
561
595
  if (extraArgs.length > 0) {
562
- // if custom is an array this turns it into an object with integer keys
563
- custom = merge(custom);
564
- custom.extraArgs = extraArgs;
596
+ if (!custom) custom = nonCircularClone({});
597
+ custom.extraArgs = nonCircularClone(extraArgs);
565
598
  }
566
599
 
567
600
  var item = {
@@ -606,7 +639,7 @@ function addErrorContext(item, errors) {
606
639
  try {
607
640
  for (var i = 0; i < errors.length; ++i) {
608
641
  if (errors[i].hasOwnProperty('rollbarContext')) {
609
- custom = merge(custom, errors[i].rollbarContext);
642
+ custom = merge(custom, nonCircularClone(errors[i].rollbarContext));
610
643
  contextAdded = true;
611
644
  }
612
645
  }
@@ -4548,7 +4581,7 @@ module.exports = {
4548
4581
 
4549
4582
 
4550
4583
  module.exports = {
4551
- version: '2.24.0',
4584
+ version: '2.24.1',
4552
4585
  endpoint: 'api.rollbar.com/api/1/item/',
4553
4586
  logLevel: 'debug',
4554
4587
  reportLevel: 'debug',