(garbage-collection): cdk gc takes hours on a large bootstrap bucket
Maintainer thường phản hồi trong vòng 1 ngày
@dveldhoen đang làm issue này rồi.
Từ ngày 17/11/2026.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- aws, typescript
Hướng nghiên cứu
Read packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/garbage-collector.ts around parallelReadAllTags, parallelTagS3 and parallelUntagS3, then inspect packages/aws-cdk/lib/cli/proxy-agent.ts around the ProxyAgent configuration. Check how the existing parallelPromises helper and SDK HTTP agent options are used. Done means S3 tag calls run concurrently up to the limiter's 50-call limit and reuse connections; the issue reports a 24,400-object scan completing in minutes with both fixes.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
cdk gc reads and writes S3 object tags one call at a time, and the CLI opens a new TLS connection for every call. On a bootstrap bucket with about 24,000 objects, a run takes hours. In CI it got through about 2,000 objects in 30 minutes before the job timed out, and because every run starts again at the beginning of the bucket, it never caught up.
There are two causes:
parallelReadAllTags,parallelTagS3andparallelUntagS3await each call inside their loop, so thepLimit(50)limiter never has more than one call in flight:
https://github.com/aws/aws-cdk-cli/blob/9f41f76683c1dfcf80b356a8c1e77094da97ef54/packages/%40aws-cdk/toolkit-lib/lib/api/garbage-collection/garbage-collector.ts#L423-L429- The CLI passes its
ProxyAgentto the SDK ashttpsAgent. That replaces the SDK's default agent, which@smithy/node-http-handlercreates withkeepAlive: trueandmaxSockets: 50, with one that has no keep-alive, so every SDK call opens a new connection:
https://github.com/aws/aws-cdk-cli/blob/9f41f76683c1dfcf80b356a8c1e77094da97ef54/packages/aws-cdk/lib/cli/proxy-agent.ts#L137-L143
Regression Issue
- Select this option if this issue appears to be a regression.
Last Known Working CDK Version
No response
Expected Behavior
cdk gc runs up to 50 tag calls at a time, as the limiter intends, over reused connections, and finishes a bucket of this size in minutes.
Current Behavior
Tag calls run one at a time, each over a new TLS connection. From a GitHub-hosted runner to a bucket in another region, a run processed about 1 object per second and hit the 30-minute job timeout every time.
Reproduction Steps
- Use an environment whose bootstrap bucket holds many objects, for example 20,000 or more, which accumulate on an account that deploys several times a day.
- Run
cdk gc aws://<account>/<region> --unstable=gc --type=s3 --action=print. - The scan progresses at roughly one object per network round trip plus a TLS handshake.
Possible Solution
Run the S3 tag calls through the existing parallelPromises helper with the same limit, and pass keepAlive: true to the CLI's ProxyAgent. I'll open a PR for each.
With both fixes applied as a local patch (Promise.all through the existing limiter, plus keep-alive), a local cdk gc --unstable=gc --action=print scan (no tagging or deleting) of the whole bucket (about 24,400 objects) and its ECR repository finished in 137 seconds. With only the first change, about 4,000 objects took 6 minutes, and the run then ended with S3GarbageCollectionFailed: TimeoutError: read ECONNRESET.
Additional Information/Context
The ECR loops (parallelTagEcr, parallelUntagEcr) follow the same pattern. I left them out of the PRs to keep to the S3 path I measured. ECR's API rate quotas are lower than S3's, so running those calls concurrently deserves its own look.
CDK CLI Version
2.1148.1 (build fcf5e34)
Framework Version
2.277.0
Node.js Version
24.22.2
OS
Ubuntu 24.04 (GitHub Actions) and macOS
Language
TypeScript
Language Version
No response
Other information
No response
- Ngôn ngữ chính
- TypeScript
- Star
- 110
- Fork
- 138
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 55
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của aws/aws-cdk-cli
-
aws-cdk bug needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
aws/aws-cdk-cli#2179 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
(cli): deploy waits forever when an AWS API call gets no response, because requestTimeout only logs a warningCó thể đã có người làm @abhiramshaji-cyber đã nhận 27 ngày trước. Đang mởaws-cdk bug p2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
aws/aws-cdk-cli#2097 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
(bootstrap) FilePublishingRoleDefaultPolicy permission incorrect when FileAssetsBucketKmsKeyId is an ARN valueCó thể đã có người làm @lemon0333 đã nhận 95 ngày trước. Đang mởbug p2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
aws/aws-cdk-cli#921 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
(cli): cdk flags --set always reports no template differences before applying flagsCó thể đã có người làm @go-to-k đã nhận 10 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
aws/aws-cdk-cli#2153 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
integ-runner: update workflow fails when deploying an existing snapshotCó thể đã có người làm @gibkim đã nhận 11 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 32/100
aws/aws-cdk-cli#2150 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của aws/aws-cdk-cli
Issue tương tự
-
generate_image reference URL guard lets through IPv4-mapped IPv6 hosts and 100.64.0.0/10Có thể đã có người làm @goranai đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Inbox permission: an allow sent with `updatedInput` is ignored by Claude Code on its own safety checksCó thể đã có người làm @Raj1v đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
backnotprop/plannotator#4046 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
進捗部屋の管理画面で削除対象を月ごとに絞り込むĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
traPtitech/knoQ_R-UI#290 ·
Maintainer thường phản hồi trong vòng 24 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
farion1231/cc-switch#9981 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
account bug course exam iris lecture
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày