Skip to content

Include container logs in the error when a container fails to start #1506

Open

Description

@cristianrgreco

What happens

When a container fails its wait strategy, waitForContainer stops and removes the container and rethrows the wait strategy's error. The error says only what timed out, for example:

URL /health not accessible after 60000ms

The container's own output is gone by then, so the caller can't tell why it never became ready. The only way to see it is to attach a log consumer before start() and print the buffer in a catch.

Expected

The error thrown from start() includes the last lines of the container's logs. The HTTP wait already does this on its abortOnContainerExit path ("Container exited during HTTP healthCheck, last 50 logs: ...").

Where

packages/testcontainers/src/wait-strategies/wait-for-container.ts, which removes the container before rethrowing.

Notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions