From dd29e215726eb9cb2c5170837c49a0c931b7e683 Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Wed, 9 Feb 2022 08:56:09 -0800 Subject: [PATCH 1/2] make new non-enumerable properties mutable, fix docstring --- packages/utils/src/object.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/utils/src/object.ts b/packages/utils/src/object.ts index c6e532111724..f359a891c900 100644 --- a/packages/utils/src/object.ts +++ b/packages/utils/src/object.ts @@ -42,16 +42,18 @@ export function fill(source: { [key: string]: any }, name: string, replacementFa } /** - * Defines a non enumerable property. This creates a non enumerable property on an object. + * Defines a non-enumerable property on the given object. * - * @param func The function to set a property to - * @param name the name of the special sentry property - * @param value the property to define + * @param obj The object on which to set the property + * @param name The name of the property to be set + * @param value The value to which to set the property */ -// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types -export function addNonEnumerableProperty(func: any, name: string, value: any): void { - Object.defineProperty(func, name, { +export function addNonEnumerableProperty(obj: { [key: string]: unknown }, name: string, value: unknown): void { + Object.defineProperty(obj, name, { + // enumerable: false, // the default, so we can save on bundle size by not explicitly setting it value: value, + writable: true, + configurable: true, }); } From 308f4447513675ae39bd41ebb4247aaf6d91e780 Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Wed, 9 Feb 2022 09:17:27 -0800 Subject: [PATCH 2/2] cast exception to object when marking it seen --- packages/utils/src/misc.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/utils/src/misc.ts b/packages/utils/src/misc.ts index fa98490629bb..11f823115215 100644 --- a/packages/utils/src/misc.ts +++ b/packages/utils/src/misc.ts @@ -277,7 +277,7 @@ export function checkOrSetAlreadyCaught(exception: unknown): boolean { try { // set it this way rather than by assignment so that it's not ennumerable and therefore isn't recorded by the // `ExtraErrorData` integration - addNonEnumerableProperty(exception, '__sentry_captured__', true); + addNonEnumerableProperty(exception as { [key: string]: unknown }, '__sentry_captured__', true); } catch (err) { // `exception` is a primitive, so we can't mark it seen }