-
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 80.84% 80.85%
=======================================
Files 232 232
Lines 14135 14138 +3
Branches 2460 2461 +1
=======================================
+ Hits 11428 11431 +3
Misses 2427 2427
Partials 280 280
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!
➡️ PR build request submitted to A maintainer must now check the pipeline and add the |
✅ 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. |
Pinging for an update |
// This is because if this.setInterval is reassigned to another setInterval, | ||
// the original setInterval remains and can no longer be cleared. | ||
if (this.setInterval) { | ||
throw new Error('ProgressPrinter is already running. Stop it first using the stop() method before starting it again.'); |
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.
throw new Error('ProgressPrinter is already running. Stop it first using the stop() method before starting it again.'); | |
throw new ToolkitError('ProgressPrinter is already running. Stop it first using the stop() method before starting it again.'); |
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.
import { ToolkitError } from '../../toolkit/error';
^ needs to be added at the top of this file @sakurai-ryo. I don't have push access to your fork.
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.
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.
@sakurai-ryo sorry to bother but i don't have access to push to your fork so I can't make this final change on my own
…rai-ryo/aws-cdk into fix-garbage-collector-timer
Pull request has been modified.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
@kaizencc I committed this change on my end, please check again. |
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