Skip to content

Increase timeout for waiting for host port bindings to 30 seconds - #1494

Merged
cristianrgreco merged 1 commit into
mainfrom
claude/address-feedback-1447-ba8199
Oct 10, 2026
Merged

cristianrgreco merged 1 commit into
mainfrom
claude/address-feedback-1447-ba8199

Conversation

@cristianrgreco

Copy link
Copy Markdown
Collaborator

Summary

GenericContainer waits for the host port bindings to appear in the inspect result before the wait strategy runs. That wait had a fixed 10 second limit, which is not enough on CPU-constrained hosts: #1446 measured port binding taking up to 16.7 seconds with six containers starting concurrently on a 2-vCPU runner.

This raises the fixed limit to 30 seconds. It applies to start(), starting a stopped reused container, and restart(), which all share the same default.

The limit stays independent of withStartupTimeout(). Tying the two together (the approach in #1447) lets each phase consume the full startup timeout, so a 10 minute timeout could wait close to 20 minutes.

Verification

  • npm run format
  • npm run lint
  • npm run check-compiles
  • npx vitest run on inspect-container-util-ports-exposed.test.ts, generic-container-auto-cleanup.test.ts, generic-container-restart.test.ts and generic-container-reuse.test.ts

Test results

  • Format, lint and check-compiles are clean.
  • The four test files pass (21 tests).
  • Fault injection, not committed: a test that wraps client.container.inspect to report ports as unbound for 15 seconds after the container starts.
    • On main it fails with Timed out after 10000ms while waiting for container ports to be bound to the host.
    • With this change it passes for both start() and restart().

No test is added for the new value: asserting it needs either a 30 second real wait or a check of the constant itself.

Not breaking

There is no API change. The only behaviour change is that a container whose ports never bind now fails after 30 seconds instead of 10.

Closes #1446

Port binding can take longer than 10 seconds on CPU-constrained hosts (16.7 seconds measured in #1446).
@cristianrgreco cristianrgreco added bug Something isn't working patch Backward compatible bug fix labels Oct 10, 2026
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d958d3aa-4143-44e1-a559-18404a97ccd3

📥 Commits

Reviewing files that changed from the base of the PR and between 09adf83 and 86e2410.


📒 Files selected for processing (1)
  • packages/testcontainers/src/generic-container/inspect-container-util-ports-exposed.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review.



📝 Walkthrough

Walkthrough

The default timeout for inspectContainerUntilPortsExposed increases from 10,000 ms to 30,000 ms. Its retry and error behavior is unchanged.


Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 86e24

When a host port does not bind, startup-related operations may wait up to 30 seconds rather than 10. This is the stated behavior, and no actionable merge risk remains.

Pre-merge checks | Passed 3 | Failed 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check Warning Issue #1446 identifies the pre-wait timeout as a coding defect and proposes using this.startupTimeoutMs at both call sites. The PR changes only the utility default from 10,000 ms to 30,000 ms. `gene… Pass this.startupTimeoutMs to inspectContainerUntilPortsExposed at both call sites, or update issue #1446 to define the fixed 30-second behavior as the accepted requirement.
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: increasing the host port binding wait timeout to 30 seconds.
Description check Passed The description directly explains the timeout change, its motivation, affected flows, verification, and behavior impact.
Out of Scope Changes check Passed The only change is the default timeout in inspect-container-util-ports-exposed.ts. This change directly addresses issue #1446's host-port-binding timeout and does not add unrelated behavior.

Full details: Linked Issues check

Explanation

Issue #1446 identifies the pre-wait timeout as a coding defect and proposes using this.startupTimeoutMs at both call sites. The PR changes only the utility default from 10,000 ms to 30,000 ms. generic-container.ts still omits the timeout argument for both reused-container and new-container starts, so withStartupTimeout(...) remains ignored by this pre-wait. The fixed 30-second value addresses the reported 16.7-second measurement, but it does not implement the issue's stated configurable-timeout requirement.


  • Fix all pre-merge checks with AI
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

@cristianrgreco
cristianrgreco merged commit 2cea763 into main Oct 10, 2026
809 of 814 checks passed
@cristianrgreco
cristianrgreco deleted the claude/address-feedback-1447-ba8199 branch October 10, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working patch Backward compatible bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

withStartupTimeout() is not applied to the port-binding pre-wait (hardcoded 10 s) — measured under CPU contention

1 participant