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

(cli): cdk watch does not recover if there is an error in cdk stack/app #27864

Open
ssingh-01 opened this issue Nov 6, 2023 · 2 comments · May be fixed by #30874
Open

(cli): cdk watch does not recover if there is an error in cdk stack/app #27864

ssingh-01 opened this issue Nov 6, 2023 · 2 comments · May be fixed by #30874
Assignees
Labels
bug This issue is a bug. cli Issues related to the CDK CLI effort/small Small work item – less than a day of effort p2 package/tools Related to AWS CDK Tools or CLI

Comments

@ssingh-01
Copy link

ssingh-01 commented Nov 6, 2023

Describe the bug

If I made an error that does not resolve into a valid cloudformation, cdk watch throws the error on console. However, if I fix that issue, I would expect cdk to detect the issue to resolve and deploy the correct cloudformation template. CDK watch gets hung instead.

Expected Behavior

Expect cdk watch to redeploy once the error has been fixed.

Current Behavior

If I made an error that does not resolve into a valid cloudformation, cdk watch throws the error on console. However, if I fix that issue, CDK watch gets hung. It detects the change but does not deploy.

Reproduction Steps

This is a valid stack and app :

app = App()
ApiEventBridgeLambdaStack(app, "ApiEventBridgeLambdaStack")

If I update it to the following while cdk watch is running, cdk watch will throw the error but stays hung after I fix the error (remove a mistyped N in this case):

app = App()
ApiEventBridgeLambdaStack(appN, "ApiEventBridgeLambdaStack")

This happens with stack level changes as well.

Detects change but does not deploy, stays in hung state :

image

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

v2.100.0

Framework Version

No response

Node.js Version

v18.16.0

OS

MAC

Language

Python

Language Version

3.10.6

Other information

Reproducible with typescript too
Workaround is to interrupt the terminal and re run cdk watch.

@ssingh-01 ssingh-01 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 6, 2023
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Nov 6, 2023
@khushail
Copy link
Contributor

khushail commented Nov 6, 2023

thanks @ssingh-01 for reporting this.

@khushail khushail added effort/small Small work item – less than a day of effort p2 and removed needs-triage This issue or PR still needs to be triaged. labels Nov 6, 2023
@SankyRed SankyRed self-assigned this Apr 30, 2024
@pahud pahud added the cli Issues related to the CDK CLI label May 29, 2024
@misterjoshua
Copy link
Contributor

I'm running into this issue as well. I've been working around the issue with ctrl c and re-running cdk watch.

I think the issue is that the cdk cli isn't releasing the outdir lock when a synth fails. The problem is here:

const writerLock = await new RWLock(outdir).acquireWrite();

I think the lines that follow should live in a try/catch - when the exec fails, I think the catch should probably release the lock and rethrow the error.

@misterjoshua misterjoshua linked a pull request Jul 17, 2024 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. cli Issues related to the CDK CLI effort/small Small work item – less than a day of effort p2 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants