Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: don't capture stack traces for PostResolveToken #10456

Merged
merged 2 commits into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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