Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Support `AbortSignal` in `start()`, `exec` and other long-running calls

Đang mở
#1,560 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
docker, node.js, typescript
Lĩnh vực
backend, testing

Hướng nghiên cứu

Start by reading start and startContainer in packages/testcontainers/src/generic-container/generic-container.ts, then trace image pull and build, wait strategies, exec, and Compose up in the listed files. Check the coordination requirements for #1558, #1548, and #1582 before changing shared interfaces. Done means long-running calls accept an AbortSignal, reject with its reason on abort, and clean up partially created resources.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement minor

What happens

Nothing in the API accepts an AbortSignal.

  • start() can spend minutes pulling an image and waiting for readiness. When the test runner times the test out, or the user gives up, the start carries on in the background. The container is still created and stays until Ryuk removes it at process exit.
  • The only timeout is the wait strategy's startup timeout. It does not cover the image pull.
  • exec has no timeout and cannot be cancelled, so a command that hangs blocks its caller indefinitely.
  • DockerComposeEnvironment.up() and GenericContainerBuilder.build() are the same.

Expected

Long-running operations take a signal:

await new GenericContainer(image).start({ signal: AbortSignal.timeout(30_000) });
await container.exec(["pg_dump"], { signal });

On abort the promise rejects with the signal's reason, and whatever was half-created (container, network attachment, Compose project) is stopped and removed.

Where

  • start and startContainer in packages/testcontainers/src/generic-container/generic-container.ts
  • pull and build in packages/testcontainers/src/container-runtime/clients/image/docker-image-client.ts
  • packages/testcontainers/src/wait-strategies/*.ts
  • exec in packages/testcontainers/src/container-runtime/clients/container/docker-container-client.ts
  • up in packages/testcontainers/src/docker-compose-environment/docker-compose-environment.ts

Notes

  • Go passes a context.Context to every call. .NET takes a CancellationToken.
  • Related: #1081 asked for this. It was closed when the reporter's underlying problem turned out to be something else.
  • A startup deadline is a signal with a timeout. One mechanism can serve both this and #1582.

Dependencies

  • Stack on #1558: both change the wait strategy interface. Change it once, in the same major.
  • Coordinate with #1548: exec gains a timeout there. Make the two agree.
  • Coordinate with #1582: the deadline can be carried by the same signal.
Ngôn ngữ chính
TypeScript
Star
2.6k
Fork
274
Merge trung bình
1 ngày 14 giờ
Pull request đã merge (30 ngày)
44

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của testcontainers/testcontainers-node

Tất cả issue của testcontainers/testcontainers-node

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.