TypeError: Cannot read property 'Symbol(@aws-cdk/core.DependableTrait)' of undefined
See original GitHub issueGeneral Issue
TypeError: Cannot read property ‘Symbol(@aws-cdk/core.DependableTrait)’ of undefined
The Question
Hello,
After migrating my CDK v1 project to v2, and using the “constructs” library, a new issue popped up making it unable to deploy a CDK app:
MyProject/cdk/node_modules/constructs/src/dependency.ts:48
const ret = (instance as any)[DEPENDABLE_SYMBOL];
^
TypeError: Cannot read property 'Symbol(@aws-cdk/core.DependableTrait)' of undefined
at Function.of (MyProject/cdk/node_modules/constructs/src/dependency.ts:48:34)
at Node.get dependencies [as dependencies] (MyProject/cdk/node_modules/constructs/src/construct.ts:201:37)
at findTransitiveDeps (MyProject/cdk/node_modules/aws-cdk-lib/core/lib/private/prepare-app.ts:114:42)
at Object.prepareApp (MyProject/cdk/node_modules/aws-cdk-lib/core/lib/private/prepare-app.ts:19:28)
at Object.synthesize (MyProject/cdk/node_modules/aws-cdk-lib/core/lib/private/synthesis.ts:32:3)
at App.synth (MyProject/cdk/node_modules/aws-cdk-lib/core/lib/stage.ts:90:23)
at process.<anonymous> MyProject/cdk/node_modules/aws-cdk-lib/core/lib/app.ts:64:45)
at Object.onceWrapper (node:events:514:26)
at process.emit (node:events:394:28)
at process.emit (node:domain:470:12)
My package.json file:
{
"name": "cdk",
"version": "0.1.0",
"bin": {
"cdk": "bin/cdk.js"
},
"scripts": {
"build": "tsc",
"watch": "tsc -w",
"test": "jest",
"cdk": "cdk"
},
"devDependencies": {
"@aws-cdk/assert": "^2.10.0",
"@types/aws-lambda": "^8.10.92",
"@types/jest": "^27.4.0",
"@types/node": "^17.0.14",
"aws-cdk": "^2.10.0",
"jest": "^27.4.7",
"ts-jest": "^27.1.3",
"ts-node": "^10.4.0",
"typescript": "~4.5.5"
},
"dependencies": {
"@aws-cdk/aws-apigatewayv2-alpha": "^2.10.0-alpha.0",
"@aws-cdk/aws-apigatewayv2-authorizers-alpha": "^2.10.0-alpha.0",
"@aws-cdk/aws-apigatewayv2-integrations-alpha": "^2.10.0-alpha.0",
"@aws-sdk/client-cloudwatch-logs": "^3.45.0",
"@aws-sdk/client-dynamodb": "^3.45.0",
"@aws-sdk/client-ec2": "^3.45.0",
"@aws-sdk/client-emr": "^3.45.0",
"@aws-sdk/client-eventbridge": "^3.45.0",
"@aws-sdk/client-lambda": "^3.45.0",
"@aws-sdk/client-s3": "^3.45.0",
"@aws-sdk/client-sfn": "^3.45.0",
"@aws-sdk/client-sts": "^3.45.0",
"@slack/web-api": "^6.5.1",
"aws-cdk-lib": "^2.10.0",
"cdk": "^2.10.0",
"constructs": "^10.0.51",
"npm-check-updates": "^12.1.0",
"short-uuid": "^4.2.0",
"source-map-support": "^0.5.21"
}
}
I also installed the legacy @aws-cdk/core
but it didn’t help, as it seems that the constructs
library fails on this line:
DependencyGroup[_a] = { fqn: "constructs.DependencyGroup", version: "10.0.51" };
const DEPENDABLE_SYMBOL = Symbol.for('@aws-cdk/core.DependableTrait');
Any ideas? Thank you
CDK CLI Version
2.10.0 (build e5b301f)
Framework Version
No response
Node.js Version
v16.3.0
OS
MacOS
Language
Typescript
Language Version
4.5.5
Other information
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Have I split up these Constructs incorrectly? - Stack Overflow
No stack could be identified for the construct at path API/website-api ... 0) { ^ TypeError: Cannot read property 'length' of undefined at ......
Read more >class DependableTrait · AWS CDK
Trait for IDependable. Traits are interfaces that are privately implemented by objects. Instead of showing up in the public interface of a class,...
Read more >awslabs/aws-cdk - Gitter
JavaScriptError: TypeError: Cannot read property 'value' of undefined at Function. ... Can you try removing the other properties from your constructor?
Read more >Error in Console: "Cannot read property 'replace' of undefined"
Any Idea why I might be getting this error when trying to update a task defintition in ECS in the AWS console using...
Read more >Retrieving Resource Values as Strings - CDK for Terraform
... undefined, sensitive: undefined, dependsOn: undefined, [Symbol(@aws-cdk/core.DependableTrait)]: { dependencyRoots: [ [Circular *1] ] } }.
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 FreeTop 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
Top GitHub Comments
Commenting for future people searching about this error. This may not be the exact problem OP had, but it presented with the same error message from the issue title. So if you’re running into that error, this may help.
I had a very nearly identical problem crop up following the upgrade to 2.39.0:
This ultimately turned out to be caused because we had been using CDK in a way that worked but was undefined and unsupported. We have a lambda which needs explicitly defined subnets, for which we know the Subnet IDs.
For this, we had been using plain objects like:
This bit us when changes in 2.39.0 added checks that rely on certain nested properties of Subnets. Since we only had the
subnetId
property, accessing these nested properties failedtl;dr
The fix was to use the appropriate method (in this case
ec2.Subnet.fromSubnetId
) to construct objects that properly implement the appropriate interface… instead of creating raw objects that only implement a minimal subset of properties that happen to work for now.(this may seem like an obvious one to some folks… but if I can save someone else the afternoon I spent debugging this in my codebase, I’ll eat the embarrassment)
Ah interesting, I wonder why that was. I’m glad you got it figured out 🙂