Skip to content

Commit 77e3096

Browse files
committed
Restore world order
1 parent 26093ac commit 77e3096

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

packages/utils/src/normalize.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,11 @@ function visit(
9898
return stringified;
9999
}
100100

101-
// From here on, we can assert that `value` is either an object or an array!
101+
// From here on, we can assert that `value` is either an object or an array.
102102

103-
// If we've already visited this branch, bail out, as it's circular reference. If not, note that we're seeing it now.
104-
if (memoize(value)) {
105-
return '[Circular ~]';
106-
}
107-
108-
// Do not normalize objects that we know have already been normalized. This MUST be below the circ-ref check otherwise
109-
// we might somehow accidentally produce circular references by skipping normalization.
110-
// As a general rule, the "__sentry_skip_normalization__" property should only be used sparingly and only should only
111-
// be set on objects that have already been normalized.
103+
// Do not normalize objects that we know have already been normalized. As a general rule, the
104+
// "__sentry_skip_normalization__" property should only be used sparingly and only should only be set on objects that
105+
// have already been normalized.
112106
if ((value as ObjOrArray<unknown>)['__sentry_skip_normalization__']) {
113107
return value as ObjOrArray<unknown>;
114108
}
@@ -119,6 +113,11 @@ function visit(
119113
return stringified.replace('object ', '');
120114
}
121115

116+
// If we've already visited this branch, bail out, as it's circular reference. If not, note that we're seeing it now.
117+
if (memoize(value)) {
118+
return '[Circular ~]';
119+
}
120+
122121
// At this point we know we either have an object or an array, we haven't seen it before, and we're going to recurse
123122
// because we haven't yet reached the max depth. Create an accumulator to hold the results of visiting each
124123
// property/entry, and keep track of the number of items we add to it.

0 commit comments

Comments
 (0)