Error: true does not implement IDependable. Use "Dependable.implement()" to implement
Describe the bug
Upgrade of aws-cdk-lib from 2.22.0 to 2.26.0 introduces:
throw new Error(`${instance} does not implement IDependable. Use "Dependable.implement()" to implement`);
^
Error: true does not implement IDependable. Use "Dependable.implement()" to implement
at Function.of (/local/home/rymcg/Volumes/Workspaces/wolf/src/<redacted>/node_modules/constructs/src/dependency.ts:93:13)
at Node.get dependencies [as dependencies] (/local/home/rymcg/Volumes/Workspaces/wolf/src/<redacted>//node_modules/constructs/src/construct.ts:317:37)
at findTransitiveDeps (/local/home/rymcg/Volumes/Workspaces/wolf/src/<redacted>//node_modules/aws-cdk-lib/core/lib/private/prepare-app.js:1:1434)
at Object.prepareApp (/local/home/rymcg/Volumes/Workspaces/wolf/src/<redacted>//node_modules/aws-cdk-lib/core/lib/private/prepare-app.js:1:309)
at Object.synthesize (/local/home/rymcg/Volumes/Workspaces/wolf/src/<redacted>//node_modules/aws-cdk-lib/core/lib/private/synthesis.js:1:557)
at App.synth (/local/home/rymcg/Volumes/Workspaces/wolf/src/<redacted>//node_modules/aws-cdk-lib/core/lib/stage.js:1:1866)
at process.<anonymous> (/local/home/rymcg/Volumes/Workspaces/wolf/src/<redacted>//node_modules/aws-cdk-lib/core/lib/app.js:1:1164)
at Object.onceWrapper (events.js:520:26)
at process.emit (events.js:400:28)
at process.emit (domain.js:475:12)
when running cdk synth
Running with 2.25.0 works just fine. Upgrading to 2.26.0 breaks it, then attempting to downgrade to 2.25.0 without undoing changes to package-lock.json is still broken.
Expected Behavior
I expected stack synthesis to complete successfully
Current Behavior
Error is thrown and stack synthesis does not complete successfully
Reproduction Steps
Upgrade aws-cdk-lib from 2.22.0 to 2.26.0
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.40.0 (build 56ba2ab)
Framework Version
No response
Node.js Version
14
OS
Amazon Linux 2
Language
Typescript
Language Version
4.0.5
Other information
No response
To see where this value is coming from, can you make the following local edit to one of the Node modules on your disk, then synth again?
Edit
node_modules/constructs/lib/construct.js
And around line 247, add the following line:
addDependency(...deps) {
for (const d of deps) {
Dependable.of(d); // <-- add this
this._dependencies.add(d);
}
}
That should throw when the incorrect value is added (instead of when it is consumed, which is much later)
I found a construct that was set to true instead of an IDependable, exactly as the stack trace says. Not sure what capabilities TypeScript has in terms of printing variable names along with their values in the stack trace but that would be nice.
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
The issue here was a custom implementation of VPC that returned internetConnectivityEstablished: true, whereas that property had to be of type IDependable. Because of the way these types are defined, TypeScript unfortunately cannot type check this properly.
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
The issue here was a custom implementation of VPC that returned
internetConnectivityEstablished: true, whereas that property had to be of typeIDependable. Because of the way these types are defined, TypeScript unfortunately cannot type check this properly.
You may want to try
Dependable.implement(() => true, {
dependencyRoots: [],
} as unknown as Dependable),
@SumiSastri where about would you add that line, assuming you're writing a custom implementation of ec2.IVpc?