Include container logs in the error when a container fails to start #1506
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Description
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
- Applies to every wait strategy, not only HTTP.
- Worth checking how the other Testcontainers implementations report a failed start.
- Related: Compose container logs are only captured for successful starts #1210 (Compose logs on failed starts).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Activity