From 98236b3a0dc653e0fb6984a41261ed0a20602ca7 Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Mon, 21 Sep 2020 16:33:37 +0200 Subject: [PATCH] chore: don't capture stack traces for `PostResolveToken` One of the contributors of longer runtimes, and we definitely don't need stack traces in it. Relates to #10213. --- .../@aws-cdk/core/lib/private/intrinsic.ts | 18 ++++++++++++++++-- packages/@aws-cdk/core/lib/util.ts | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/@aws-cdk/core/lib/private/intrinsic.ts b/packages/@aws-cdk/core/lib/private/intrinsic.ts index f880162fa9015..88cbe6ee02af7 100644 --- a/packages/@aws-cdk/core/lib/private/intrinsic.ts +++ b/packages/@aws-cdk/core/lib/private/intrinsic.ts @@ -2,6 +2,20 @@ import { IResolvable, IResolveContext } from '../resolvable'; import { captureStackTrace } from '../stack-trace'; import { Token } from '../token'; +/** + * Customization properties for an Intrinsic token + * + * @experimental + */ +export interface IntrinsicProps { + /** + * Capture the stack trace of where this token is created + * + * @default true + */ + readonly stackTrace?: boolean; +} + /** * Token subclass that represents values intrinsic to the target document language * @@ -20,12 +34,12 @@ export class Intrinsic implements IResolvable { private readonly value: any; - constructor(value: any) { + constructor(value: any, options: IntrinsicProps = {}) { if (isFunction(value)) { throw new Error(`Argument to Intrinsic must be a plain value object, got ${value}`); } - this.creationStack = captureStackTrace(); + this.creationStack = options.stackTrace ?? true ? captureStackTrace() : []; this.value = value; } diff --git a/packages/@aws-cdk/core/lib/util.ts b/packages/@aws-cdk/core/lib/util.ts index 7416189a33360..6924b197667af 100644 --- a/packages/@aws-cdk/core/lib/util.ts +++ b/packages/@aws-cdk/core/lib/util.ts @@ -80,7 +80,7 @@ export function filterUndefined(obj: any): any { */ export class PostResolveToken extends Intrinsic implements IPostProcessor { constructor(value: any, private readonly processor: (x: any) => any) { - super(value); + super(value, { stackTrace: false }); } public resolve(context: IResolveContext) {