Skip to content

Use configured health checks as the default wait strategy#1096

Open
digital88 wants to merge 14 commits into
testcontainers:mainfrom
digital88:issue-687
Open

Use configured health checks as the default wait strategy#1096
digital88 wants to merge 14 commits into
testcontainers:mainfrom
digital88:issue-687

Conversation

@digital88
Copy link
Copy Markdown
Contributor

@digital88 digital88 commented Aug 3, 2025

Closes #687

Had to augment ImageInspectInfo & ContainerInspectInfo because dockerode types do not expose HealthCheck nested property in Config property. I opened PR here but not sure when it will be accepted.

@netlify
Copy link
Copy Markdown

netlify Bot commented Aug 3, 2025

Deploy Preview for testcontainers-node ready!

Name Link
🔨 Latest commit 8fe8c04
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-node/deploys/6a0743c373dcce0008d5f254
😎 Deploy Preview https://deploy-preview-1096--testcontainers-node.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@cristianrgreco cristianrgreco added enhancement New feature or request major An incompatible API change labels Aug 6, 2025
Comment thread packages/testcontainers/src/generic-container/abstract-started-container.ts Outdated
@digital88
Copy link
Copy Markdown
Contributor Author

I fixed some invalid WaitStrategy references in kafka and red panda. Tests pass locally

@digital88
Copy link
Copy Markdown
Contributor Author

@cristianrgreco
Hi, is there something else that should be done in this PR? Or we are just waiting for next major release before merging this?

@cristianrgreco
Copy link
Copy Markdown
Collaborator

@cristianrgreco Hi, is there something else that should be done in this PR? Or we are just waiting for next major release before merging this?

Hey @digital88, apologies for the delay, been super busy with work lately! I still need to review this PR, but yes you're right it'll eventually get queued for a major release.

@cristianrgreco
Copy link
Copy Markdown
Collaborator

cristianrgreco commented May 13, 2026

I've had another look at this PR (need to release a major version for dropping node 20, and wanted to add this as part of the release) and found the following issues:

  • Reused containers bypass the new selector. In generic-container.ts:164-170, the reuse path falls back directly to Wait.forListeningPorts() and only applies withStartupTimeout() to this.waitStrategy. Existing reusable containers with image/custom health checks will still wait on ports, and fallback strategies lose the configured startup timeout. Resolve the wait strategy from the reused container inspect result, then apply the timeout to that resolved strategy.

  • Disabled health checks are treated as enabled. generic-container.ts:126 and docker-compose-environment.ts:214-216 check only whether Healthcheck.Test exists. HEALTHCHECK NONE / Compose test: ["NONE"] disables health checks, so this would select Wait.forHealthCheck() for a container that never gets State.Health, causing a timeout instead of the port wait fallback. Docker and Compose both document this disable form: Dockerfile reference, Compose spec.

  • Docs still describe the old default. docs/features/wait-strategies.md:15 and docs/features/compose.md:46 still say listening ports is always the default. This PR changes public behavior, so the docs should explain health-check defaulting and explicit override behavior.

@digital88 WDYT? I notice this PR hasn't gained much traction so not sure how important it is to include. I appreciate that this PR is old (my fault) but if we can fix it up we can probably include it. I'll give it a go.

@cristianrgreco cristianrgreco changed the title Allow to use HealthCheck wait strategy by default Use configured health checks as the default wait strategy May 13, 2026
@cristianrgreco
Copy link
Copy Markdown
Collaborator

@digital88 LMK if you want to review the changes, if not I reckon we're good to merge.

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

Labels

enhancement New feature or request major An incompatible API change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default to HealthCheckWaitStrategy for containers with health checks defined

3 participants