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

fix(core): pressing Ctrl-C when content is bundled leaves broken asset #33692

Merged
merged 9 commits into from
Mar 5, 2025

Conversation

rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Mar 5, 2025

When a bundling command is interrupted with Ctrl-C, the asset output directory has already been created. On the next synthesis, we assume the asset has already successfully been produced, don't do any bundling, and upload it.

We will then have produced and uploaded a broken asset.

Instead, the common pattern to handle this is:

  • Do the work into a temporary directory
  • Rename the temporary directory to the target directory only if the work succeeds.

Closes #33201, closes #32869, relates to #14474.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

When a bundling command is interrupted with Ctrl-C, the asset output
directory has already been created. On the next synthesis, we assume the
asset has already successfully been produced, don't do any bundling, and
upload it.

We will then have produced and uploaded a broken asset.

Instead, the common pattern to handle this is:

- Do the work into a temporary directory
- Rename the temporary directory to the target directory only if the
  work succeeds.
@rix0rrr rix0rrr requested a review from a team as a code owner March 5, 2025 14:22
@aws-cdk-automation aws-cdk-automation requested a review from a team March 5, 2025 14:22
@github-actions github-actions bot added bug This issue is a bug. effort/medium Medium work item – several days of effort p2 labels Mar 5, 2025
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Mar 5, 2025
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This review is outdated)

@mrgrain mrgrain changed the title fix: pressing Ctrl-C when content is bundled leaves broken asset fix(core): pressing Ctrl-C when content is bundled leaves broken asset Mar 5, 2025
@iliapolo iliapolo added the pr/do-not-merge This PR should not be merged at this time. label Mar 5, 2025
Copy link
Contributor

@iliapolo iliapolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving with do-not-merge.

@@ -3,7 +3,7 @@
exports[`esbuild bundling with esbuild options 1`] = `
""use strict";
(() => {
// aws-lambda-nodejs/test/handlers/define.ts
// ../../../../PublicCDK/aws-cdk/packages/aws-cdk-lib/aws-lambda-nodejs/test/handlers/define.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wut wut

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

¯_(ツ)_/¯

@@ -675,6 +676,43 @@ describe('staging', () => {
]);
});

test('if bundling is interrupted, target asset directory is not produced', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to also have a test that reruns bundling that now succeeds, to ensure the existence of the -building directory doesn't break anything. Up to you though, it might be overdoing it.

@rix0rrr rix0rrr added pr-linter/exempt-integ-test The PR linter will not require integ test changes and removed pr/do-not-merge This PR should not be merged at this time. labels Mar 5, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review March 5, 2025 19:11

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

Copy link

codecov bot commented Mar 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.24%. Comparing base (4ab0b33) to head (fa5d50a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #33692      +/-   ##
==========================================
+ Coverage   82.21%   82.24%   +0.02%     
==========================================
  Files         119      119              
  Lines        6876     6875       -1     
  Branches     1162     1161       -1     
==========================================
+ Hits         5653     5654       +1     
+ Misses       1120     1118       -2     
  Partials      103      103              
Flag Coverage Δ
suite.unit 82.24% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
packages/aws-cdk ∅ <ø> (∅)
packages/aws-cdk-lib/core 82.24% <100.00%> (+0.02%) ⬆️
🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

mergify bot commented Mar 5, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: fa5d50a
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

mergify bot commented Mar 5, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 00ef50d into main Mar 5, 2025
20 checks passed
@mergify mergify bot deleted the huijbers/bundle-to-tempdir branch March 5, 2025 22:12
Copy link

github-actions bot commented Mar 5, 2025

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. contribution/core This is a PR that came from AWS. effort/medium Medium work item – several days of effort p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes
Projects
None yet
3 participants