(garbage-collection): cdk gc takes hours on a large bootstrap bucket
Los mantenedores suelen responder en 1 día
@dveldhoen ya está trabajando en esto.
Desde el 17/11/2026.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 72/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- aws, typescript
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- TypeScript
- Estrellas
- 110
- Forks
- 138
- Merge medio
- 1 d 9 h
- PR fusionados (30 d)
- 55
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de aws/aws-cdk-cli
-
aws-cdk bug needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
aws/aws-cdk-cli#2179 ·
Los mantenedores suelen responder en 1 día
-
(cli): deploy waits forever when an AWS API call gets no response, because requestTimeout only logs a warningPosiblemente ocupada @abhiramshaji-cyber la tomó hace 27 días. Abiertoaws-cdk bug p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
aws/aws-cdk-cli#2097 ·
Los mantenedores suelen responder en 1 día
-
(bootstrap) FilePublishingRoleDefaultPolicy permission incorrect when FileAssetsBucketKmsKeyId is an ARN valuePosiblemente ocupada @lemon0333 la tomó hace 95 días. Abiertobug p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
aws/aws-cdk-cli#921 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
(cli): cdk flags --set always reports no template differences before applying flagsPosiblemente ocupada @go-to-k la tomó hace 9 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
aws/aws-cdk-cli#2153 ·
Los mantenedores suelen responder en 1 día
-
integ-runner: update workflow fails when deploying an existing snapshotPosiblemente ocupada @gibkim la tomó hace 11 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 32/100
aws/aws-cdk-cli#2150 ·
Los mantenedores suelen responder en 1 día
Todos los issues de aws/aws-cdk-cli
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
volcengine/OpenViking#8432 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
jupyterlab/eslint-plugin#178 · 2 comentarios ·
-
bug from-app needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
nightly-labs/openbot#16303 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100