-
Notifications
You must be signed in to change notification settings - Fork 4k
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
(aws-cdk-lib): asynchronous build with unhandled errors cause deployment malfunctions #17944
Comments
Hi @ChristopheBougere! Thanks for the bug report. I wasn't able to reproduce this bug on my end following your steps. Setting the aws-cdk/packages/@aws-cdk/aws-opensearchservice/lib/domain.ts Lines 1222 to 1224 in 15d3889
Is it possible that you are not using the |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
Hi @kaizen3031593 |
Also, my error seems very similar to this one: |
I can confirm that this is not an issue with the opensearch module itself, it happens for any error thrown at deployment time. The issue comes from the way errors are handled. I solved it by adding a try/catch with a Before #!/usr/bin/env node
import { App } from 'aws-cdk-lib';
async function build() {
const app = new App();
// resolving config...
new MyProjectStack(app, 'my-project');
}
build(); After #!/usr/bin/env node
import { App } from 'aws-cdk-lib';
async function build() {
try {
const app = new App();
// resolving config...
new MyProjectStack(app, 'my-project');
} catch {
console.error('CDK unhandled error:', error);
process.exit(1);
}
}
build(); @kaizen3031593 Feel free to close the issue. However, I feel there might have been a change in how unhandled errors are catched in cdk v2 (prior to uprade, cdk thrown errors use to fail deployment properly). |
@ChristopheBougere I am going to reroute your issue to CDK v2 and @njlynch but I am not sure what, if anything, we can do about building asynchronously. |
Generally, we haven't historically supported async processing within constructs. See #8273 for a long thread on some of the rationale (and counter-arguments) to why that is. That being said, I'm intrigued by the claim that it worked in v1 but not v2. Can you provide a reproducible example that we can synth/deploy on v1 vs v2 and see what's changed? |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
Thanks for pointing to this thread @njlynch |
|
What is the problem?
I have a CDK project deployed with an OpenSearch Domain with availability zone awareness.
To reduce costs, I wanted to reduce the number of nodes in my dev env.
I changed the dataNodes to 1, as well as the availabilityZoneCount.
This was a mistake, because availabilityZoneCount should be at least 2 (or we should simply set zoneAwareness to undefined to disable it).
However, it resulted in an unhandled error (see log below) and in the complete removal of the construct that contained the OpenSearch domain.
Reproduction Steps
What did you expect to happen?
The deployment should have just failed, instead of deleting one of my constructs.
What actually happened?
The error was unhandled, and one of my construct (the one in which an error happened) was totally suppressed.
CDK CLI Version
2.1.0
Framework Version
2.1.0
Node.js Version
v14.16.0
OS
macOS Monterey 12.0.1
Language
Typescript
Language Version
3.9.7
Other information
This is, indeed, a very critical bug 😬
The text was updated successfully, but these errors were encountered: