Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Add a function-based wait strategy

オープン
#1,559 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
56/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
docker, node.js, typescript
領域
backend, testing

調査の方向性

Start by reading packages/testcontainers/src/wait-strategies/wait.ts and the existing strategies in packages/testcontainers/src/wait-strategies/ to understand their polling and timeout behavior. The issue depends on #1558 for passing the container to the predicate, though it notes an internal adapter could be used first. Done means a function based strategy polls until ready, treats rejected promises as not ready, and includes the last error on timeout.

索引モデルが issue の本文から書いたものです。

説明

enhancement minor

What happens

There is no way to say "the container is ready when this function says so". A readiness check that the built-in strategies do not cover, such as "a query succeeds" or "the topic exists", needs a class:

  • subclass StartupCheckStrategy, which receives a raw Dockerode client and a container id and returns "PENDING" | "SUCCESS" | "FAIL", or
  • implement WaitStrategy in full, including the timeout bookkeeping.

The usual alternative is to let start() return and then poll in the test with a hand-written retry loop.

Expected

A function-based strategy that is polled until it returns true, with the standard startup timeout:

const container = await new GenericContainer(image)
  .withExposedPorts(5432)
  .withWaitStrategy(
    Wait.forPredicate(async (container) => {
      const result = await container.exec(["pg_isready"]);
      return result.exitCode === 0;
    })
  )
  .start();

A rejected promise counts as "not ready yet", and the last error is included when the wait times out.

Where

  • packages/testcontainers/src/wait-strategies/wait.ts
  • a new strategy in packages/testcontainers/src/wait-strategies/

Notes

  • .NET's IWaitUntil is a single UntilAsync(IContainer) method added with AddCustomWaitStrategy. Go has wait.ForNop(func(ctx, target) error), wait.ForSQL and wait.ForExec.
  • Depends on what a strategy is given: with #1558 the predicate simply receives the container. It can be built before that by constructing the argument internally.
  • Polling must use a deterministic check from the caller. This is not a place for a sleep.

Dependencies

  • Blocked by #1558: the predicate should receive the container. It can be built first with an internal adapter if needed.
主要言語
TypeScript
スター
2.6k
フォーク
274
平均マージ
1日 14時間
マージ済み PR(30日)
44

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

testcontainers/testcontainers-node のほかの issue

testcontainers/testcontainers-node の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。