Skip to content

Commit d0fef33

Browse files
lforstAbhiPrasad
authored andcommitted
fix(integrations): Mark ExtraErrorData as already normalized (#5053)
1 parent 1fe7a02 commit d0fef33

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

packages/integrations/src/extraerrordata.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Event, EventHint, EventProcessor, ExtendedError, Hub, Integration } from '@sentry/types';
2-
import { isError, isPlainObject, logger, normalize } from '@sentry/utils';
1+
import { Contexts, Event, EventHint, EventProcessor, ExtendedError, Hub, Integration } from '@sentry/types';
2+
import { addNonEnumerableProperty, isError, isPlainObject, logger, normalize } from '@sentry/utils';
33

44
import { IS_DEBUG_BUILD } from './flags';
55

@@ -53,23 +53,22 @@ export class ExtraErrorData implements Integration {
5353
if (!hint || !hint.originalException || !isError(hint.originalException)) {
5454
return event;
5555
}
56-
const name = (hint.originalException as ExtendedError).name || hint.originalException.constructor.name;
56+
const exceptionName = (hint.originalException as ExtendedError).name || hint.originalException.constructor.name;
5757

5858
const errorData = this._extractErrorData(hint.originalException as ExtendedError);
5959

6060
if (errorData) {
61-
let contexts = {
61+
const contexts: Contexts = {
6262
...event.contexts,
6363
};
6464

6565
const normalizedErrorData = normalize(errorData, this._options.depth);
66+
6667
if (isPlainObject(normalizedErrorData)) {
67-
contexts = {
68-
...event.contexts,
69-
[name]: {
70-
...normalizedErrorData,
71-
},
72-
};
68+
// We mark the error data as "already normalized" here, because we don't want other normalization procedures to
69+
// potentially truncate the data we just already normalized, with a certain depth setting.
70+
addNonEnumerableProperty(normalizedErrorData, '__sentry_skip_normalization__', true);
71+
contexts[exceptionName] = normalizedErrorData;
7372
}
7473

7574
return {

0 commit comments

Comments
 (0)