-
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
fix(cli): old setInterval remains and is not cleared #32985
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter fails with the following errors:
❌ CLI code has changed. A maintainer must run the code through the testing pipeline (git fetch origin pull/32985/head && git push -f origin FETCH_HEAD:test-main-pipeline), then add the 'pr-linter/cli-integ-tested' label when the pipeline succeeds.
If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed, add Clarification Request
to a comment.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #32985 +/- ##
=======================================
Coverage 81.48% 81.48%
=======================================
Files 226 226
Lines 13768 13770 +2
Branches 2416 2417 +1
=======================================
+ Hits 11219 11221 +2
Misses 2271 2271
Partials 278 278
Flags with carried forward coverage won't be shown. Click here to find out more.
|
// If there is already a running setInterval, clear it first. | ||
// This is because if this.setInterval is reassigned to another setInterval, | ||
// the original setInterval remains and can no longer be cleared. | ||
if (this.setInterval) { | ||
clearInterval(this.setInterval); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good find, but I'd rather see this thrown an exception saying that stop()
should have been called first.
The problem is not that start()
doesn't do what it should, the problem is that the consumer is calling this class incorrectly, but it's not obvious that it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that makes sense.
f7726d9
// Process objects in batches of 1000 | ||
// This is the batch limit of s3.DeleteObject and we intend to optimize for the "worst case" scenario | ||
// where gc is run for the first time on a long-standing bucket where ~100% of objects are isolated. | ||
for await (const batch of this.readBucketInBatches(s3, bucket, batchSize, currentTime)) { | ||
await backgroundStackRefresh.noOlderThan(600_000); // 10 mins | ||
printer.start(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like the actual fix!
The pull request linter fails with the following errors:
PRs must pass status checks before we can provide a meaningful review. If you would like to request an exemption from the status checks or clarification on feedback, please leave a comment on this PR containing |
➡️ PR build request submitted to A maintainer must now check the pipeline and add the |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
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). |
@Mergifyio update |
❌ Mergify doesn't have permission to updateFor security reasons, Mergify can't update this pull request. Try updating locally. |
Issue # (if applicable)
Related to #32742
Reason for this change
In the
garbageCollectS3
andgarbageCollectEcr
functions, a newsetInterval
is created in theProgressPrinter
class each time the for-await loop runs.As a result, the old
setInterval
can no longer be referenced viathis.setInterval
, and because it cannot be cleared, the messages continue to be displayed.aws-cdk/packages/aws-cdk/lib/api/garbage-collection/progress-printer.ts
Line 44 in 899965d
This behavior is the same as what occurs in the simple sample code below.
Description of changes
It didn't seem necessary to initialize
setInterval
each time the for-await loop runs, so I modified the code to call.start()
before the loop begins.Describe any new or updated permissions being added
Nothing.
Description of how you validated changes
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license