Skip to content

Commit

Permalink
chore: don't capture stack traces for PostResolveToken (#10456)
Browse files Browse the repository at this point in the history
One of the contributors of longer runtimes, and we definitely
don't need stack traces in it.

Relates to #10213.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
rix0rrr authored Sep 21, 2020
1 parent 9bf8e13 commit 114b093
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions packages/@aws-cdk/core/lib/private/intrinsic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/core/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 114b093

Please sign in to comment.