Conversation
commit: |
b5fbe48 to
16d60fe
Compare
Fixes wevm#66. The testcontainers Tempo instance used withNetworkMode('host') which only works on Linux. On macOS, Docker Desktop runs in a VM so host networking doesn't expose ports to the Mac host. Changes: - testcontainers/Instance.ts: Replace withNetworkMode('host') with withExposedPorts(containerPort), return dynamic {host, port} from started.getHost()/getMappedPort() after container start - Instance.ts: Widen internal start() return type to allow {host?, port?}, convert host/port to let+getters so they update dynamically after start resolves - Instance.test.ts: Add regression tests for dynamic host/port propagation and void-return backward compatibility
16d60fe to
4e6baf0
Compare
Contributor
Author
|
tests will fail until #70 lands due to tempo timeout |
tmm
approved these changes
Mar 24, 2026
brendanjryan
added a commit
to brendanjryan/prool
that referenced
this pull request
Mar 24, 2026
tmm
pushed a commit
that referenced
this pull request
Mar 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #66.
Instance.tempo()fromprool/testcontainersdoesn't work on macOS because it useswithNetworkMode('host'), which only works on Linux. On macOS, Docker Desktop runs containers in a Linux VM, so host networking doesn't expose ports to the Mac host.Solution
Replace
withNetworkMode('host')withwithExposedPorts(containerPort)and use Testcontainers' standard port mapping APIs (getHost()/getMappedPort()) to discover the actual endpoint after the container starts.Since the
Instance.define()wrapper previously frozehost/portas constants atcreate()time, the innerstart()return type is widened to optionally return{ host?, port? }. When returned, these values update the instance's exposedhost/portgetters before the publicstart()promise resolves — soPoolandServerconsumers see the correct mapped endpoint with no changes needed.Aside: Why not fixed host-port binding?
Using
{ container: port, host: port }would avoid the interface change but introduces a TOCTOU race betweengetPort()and Docker's bind — especially problematic on Docker Desktop where startup latency widens the window. Random mapped ports are the Testcontainers-recommended approach and work better with parallel test runs.