Describe the bug
Calling Template.fromStack(stack) on some (CDK) stacks results in a (JavaScript) stack overflow
Expected Behavior
Either it synthesizes a template, or prints a helpful error
Current Behavior
RangeError: Maximum call stack size exceeded
at Set.values (<anonymous>)
at recurse (/Users/chrisr/dev/cdk-test/node_modules/aws-cdk-lib/assertions/lib/private/cyclic.js:3:2297)
at recurse (/Users/chrisr/dev/cdk-test/node_modules/aws-cdk-lib/assertions/lib/private/cyclic.js:3:2361)
at recurse (/Users/chrisr/dev/cdk-test/node_modules/aws-cdk-lib/assertions/lib/private/cyclic.js:3:2361)
at recurse (/Users/chrisr/dev/cdk-test/node_modules/aws-cdk-lib/assertions/lib/private/cyclic.js:3:2361)
at recurse (/Users/chrisr/dev/cdk-test/node_modules/aws-cdk-lib/assertions/lib/private/cyclic.js:3:2361)
at recurse (/Users/chrisr/dev/cdk-test/node_modules/aws-cdk-lib/assertions/lib/private/cyclic.js:3:2361)
at recurse (/Users/chrisr/dev/cdk-test/node_modules/aws-cdk-lib/assertions/lib/private/cyclic.js:3:2361)
at recurse (/Users/chrisr/dev/cdk-test/node_modules/aws-cdk-lib/assertions/lib/private/cyclic.js:3:2361)
at recurse (/Users/chrisr/dev/cdk-test/node_modules/aws-cdk-lib/assertions/lib/private/cyclic.js:3:2361)
Reproduction Steps
interface MyTriggerProps extends NodejsFunctionProps {
executeAfter?: IConstruct[];
executeBefore?: IConstruct[];
}
class MyTrigger extends Construct {
public readonly fn: NodejsFunction;
constructor(scope: Construct, id: string, props: MyTriggerProps) {
super(scope, id);
this.fn = new NodejsFunction(this, "Function", {
entry: props.entry,
handler: props.handler,
functionName: props.functionName,
});
const trigger = new Trigger(this, "Trigger", {
handler: this.fn,
});
trigger.executeAfter(...(props.executeAfter ?? []));
trigger.executeBefore(...(props.executeBefore ?? []));
}
}
export class CdkTestStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const triggerHello = new MyTrigger(this, "TriggerHello", {
handler: "handler",
entry: join(__dirname, "lmb/hello.ts"),
functionName: "hello",
});
const triggerGoodbye = new MyTrigger(this, "TriggerGoodbye", {
handler: "handler",
entry: join(__dirname, "lmb/goodbye.ts"),
functionName: "goodbye",
});
const triggerMiddle = new MyTrigger(this, "TriggerMiddle", {
handler: "handler",
entry: join(__dirname, "lmb/middle.ts"),
functionName: "middle",
executeAfter: [triggerHello.fn],
executeBefore: [triggerGoodbye.fn],
});
}
}
const app = new cdk.App();
let stack = new CdkTestStack(app, 'CdkTestStack');
const template = Template.fromStack(stack);
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.92.0
Framework Version
No response
Node.js Version
18.14.1
OS
macOS 13.4
Language
Typescript
Language Version
No response
Other information
No response
Describe the bug
Calling
Template.fromStack(stack)on some (CDK) stacks results in a (JavaScript) stack overflowExpected Behavior
Either it synthesizes a template, or prints a helpful error
Current Behavior
Reproduction Steps
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.92.0
Framework Version
No response
Node.js Version
18.14.1
OS
macOS 13.4
Language
Typescript
Language Version
No response
Other information
No response