[assert] RangeError: Maximum call stack size exceeded
See original GitHub issueAfter trying to update some projects to AWS CDK 1.68.0 I’m seeing the following behavior in our unit tests:
RangeError: Maximum call stack size exceeded
at deepCopy (node_modules/@aws-cdk/cloudformation-diff/lib/diff-template.ts:168:18)
at deepCopy (node_modules/@aws-cdk/cloudformation-diff/lib/diff-template.ts:176:18)
at Array.map (<anonymous>)
at deepCopy (node_modules/@aws-cdk/cloudformation-diff/lib/diff-template.ts:170:14)
[...]
at deepCopy (node_modules/@aws-cdk/cloudformation-diff/lib/diff-template.ts:176:18)
at Array.map (<anonymous>)
at deepCopy (node_modules/@aws-cdk/cloudformation-diff/lib/diff-template.ts:170:14)
cdk synth
for the stack in question seems to produce a proper template. Any ideas what might cause this?
Reproduction Steps
The test cases are pretty much in this form:
import { expect as expectCDK, matchTemplate, MatchStyle } from '@aws-cdk/assert';
import * as cdk from '@aws-cdk/core';
import { ExampleStack } from '../lib/example-stack';
test('ExampleStack', () => {
const app = new cdk.App();
// WHEN
const stack = new ExampleStack(app, `ecs-stack`);
// THEN
const expected = {
'Resources': {
/// ... resource definitions
}
};
expectCDK(stack).to(matchTemplate(expected, MatchStyle.SUPERSET));
});
Environment
- CLI Version : 1.68.0
- Framework Version: 1.68.0
- Node.js Version: v14.8.0
- OS : macOs
- Language (Version): TypeScript 4
Other
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
JavaScript RangeError: Maximum Call Stack Size Exceeded
The RangeError: Maximum call stack size exceeded is thrown when a function call is made that exceeds the call stack size. This can...
Read more >node.js - node_modules/mongodb/src/bson.ts:38:3
Testing with mongoose and typescript: RangeError: Maximum call stack size exceeded - node_modules/mongodb/src/bson.ts:38:3.
Read more >Avoid Maximum call stack size exceeded in JavaScript
Error Maximum call stack size exceeded is raised when calling a recursive function in a loop · This is expected – as every...
Read more >KJS / IR: "RangeError: Maximum call stack size exceeded ...
KJS / IR: "RangeError: Maximum call stack size exceeded": Default function overloads marked with @JsExport are broken · Problem · Expected Behaviour ·...
Read more >LWC: Maximum Callstack Size Exceeded
Likely to be this: @api alternativeText; get alternativeText() { return this.alternativeText; }. where this.alternativeText inside the get ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry for commenting on closed issue, however this is the only solution i found that helped me. Markusl is correct that this was from a version mismatch however in my case i had a version mismatch when I added a new contruct so i used npm-check -u to update all versions. Running my tests gave the exact same error above, even though my versions were in sync.
Deleting package-lock.json & node_modules and reinstalling packages fixed the issue.
@nija-at I see. I think what is different in our case was including a CDK construct with a different version (<1.68.0) of CDK libraries (and assert library) as part of the main CDK project with a library version 1.68.0. I wasn’t able to figure out why this happened, but now after upgrading the main project to CDK 1.70.0 the problem went away. I’ll get back to this if it happens again.