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

When pointing to --cdk-output with CDKv2 it throws an UnhandledPromiseRejectionWarning #74

Open
daknhh opened this issue Jan 7, 2022 · 6 comments

Comments

@daknhh
Copy link

daknhh commented Jan 7, 2022

Command: cfn-dia draw.io --cdk-output cdk.out --output-file $(sed "s/values/diagrams/g;s/.json/.drawio/g" <<< values/david-test.json) --ci-mode --skip-synth

Log:

[creatediagram] (node:73636) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'cdk.out/WAF-DAVID-INT-KY4K140S.assets.template.json' [creatediagram] at Object.openSync (fs.js:498:3) [creatediagram] at Object.readFileSync (fs.js:394:35) [creatediagram] at fromCDK (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/shared/templateParser.js:95:30) [creatediagram] at Object.get (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/shared/templateParser.js:31:16) [creatediagram] at Object.generate (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/graph/MxGenerator.js:243:41) [creatediagram] at Command.<anonymous> (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/commands/draw.io/index.js:37:23) [creatediagram] at Command.listener [as _actionHandler] (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/commander/index.js:922:31) [creatediagram] at Command._parseCommand (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/commander/index.js:1503:14) [creatediagram] at Command._dispatchSubcommand (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/commander/index.js:1443:18) [creatediagram] at Command._parseCommand (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/commander/index.js:1460:12) [creatediagram] (Use node --trace-warnings ...to show where the warning was created) [creatediagram] (node:73636) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2) [creatediagram] (node:73636) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@stefanfreitag
Copy link

Same here: I was trying to create a diagram for a stack based on CDK 2.3.0.

The error message I get is

(node:39447) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'cdk.out/my-stack-dev.assets.template.json'
    at Object.openSync (fs.js:462:3)
    at Object.readFileSync (fs.js:364:35)
    at fromCDK (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/shared/templateParser.js:96:30)
    at Object.get (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/shared/templateParser.js:31:16)
    at Object.generate (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/graph/MxGenerator.js:243:41)
    at Command.<anonymous> (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/commands/draw.io/index.js:37:23)
    at Command.listener [as _actionHandler] (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/commander/index.js:922:31)
    at Command._parseCommand (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/commander/index.js:1503:14)
    at Command._dispatchSubcommand (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/commander/index.js:1443:18)
    at Command._parseCommand (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/commander/index.js:1460:12)
(node:39447) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:39447) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

In the cdk.out directory I have

cdk.out manifest.json my-stack-dev.assets.json my-stack-dev.template.json tree.json

@obiwabrakenobi
Copy link

you might workaround with something like cdk synth > template.yaml and use the file as input like cfn-dia ... template.yaml that works for cdk v2 as well but the names look weird

@jreijn
Copy link

jreijn commented May 24, 2022

The same for me. From what I noticed you can just do cfn-dia d -t cdk.out/YOUR_STACK.template.json and it will generate the diagram.

@ljacobsson
Copy link
Owner

Sorry for the very late attention on this.

Can you please try to see if the latest release (1.1.34) fixes this. Leaving this open until I get thumbs up. Have tested with this CDK project and was able to reproduce the error and verified that the fix worked.

@RachelleJanssen
Copy link

RachelleJanssen commented Jul 1, 2022

Still getting this issue, just updated to the latest build. I was using CDK pipelines. I temporarily commented the pipeline and directly put my stack in the /bin file, then it worked. Obviously this is not ideal because it means altering CDK (and what it's going to deploy) in order to generate a diagram.

It's a CDK pipeline that deploys 2 lambdas (a simple hello world and goodbye world) in 2 accounts, each in 2 regions. When I run the rool I get a similar error as above. After cdk synth I was able to give the template path from the various folders the cdk.out folder

@ljacobsson
Copy link
Owner

@RachelleJanssen do you have a link to the project's repo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants