Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Add a function-based wait strategy

Abierto
#1,559 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
56/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
docker, node.js, typescript
Área
backend, testing

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.
Lenguaje dominante
TypeScript
Estrellas
2.6k
Forks
274
Merge medio
1 d 14 h
PR fusionados (30 d)
44

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de testcontainers/testcontainers-node

Todos los issues de testcontainers/testcontainers-node

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.