`"err"` event on log streams never fires: stderr arrives as `"data"`
Maintainer antworten meist innerhalb von 5 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 25/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- docker, node.js, typescript
- Bereich
- testing
Rechercherichtung
Start in packages/testcontainers/src/container-runtime/clients/container/docker-container-client.ts, where the log stream is demuxed by passing one PassThrough as both stdout and stderr targets, and compare it with the exec path that uses separate streams. The issue also lists the log-wait-strategy.ts and generic-container.ts err listeners. Done means settling the API direction (the author proposes options 1 to 3) with maintainers before code changes, then a test showing stderr reaching the agreed listener.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Expected Behaviour
Per the docs, stdout arrives through "data", stderr through "err".
import { GenericContainer, Wait } from "testcontainers";
await using container = await new GenericContainer("alpine")
.withCommand(["sh", "-c", "echo to-stdout; echo to-stderr >&2; sleep infinity"])
.withLogConsumer((stream) => {
stream.on("data", (line) => console.log(`data: ${line}`));
stream.on("err", (line) => console.error(`err: ${line}`));
})
.withWaitStrategy(Wait.forLogMessage("to-stderr"))
.start();
Expected output:
data: to-stdout
err: to-stderr
Actual Behaviour
Actual output:
data: to-stdout
data: to-stderr
"err" never fires. stderr arrives on "data".
Testcontainers Logs
2026-11-13T20:29:02.729Z testcontainers [DEBUG] Checking container runtime strategy "TestcontainersHostStrategy"...
2026-11-13T20:29:02.730Z testcontainers [DEBUG] Container runtime strategy "TestcontainersHostStrategy" is not applicable
2026-11-13T20:29:02.730Z testcontainers [DEBUG] Checking container runtime strategy "ConfigurationStrategy"...
2026-11-13T20:29:02.731Z testcontainers [DEBUG] Container runtime strategy "ConfigurationStrategy" is not applicable
2026-11-13T20:29:02.731Z testcontainers [DEBUG] Checking container runtime strategy "UnixSocketStrategy"...
2026-11-13T20:29:02.731Z testcontainers [TRACE] Fetching Docker info...
2026-11-13T20:29:02.776Z testcontainers [TRACE] Fetching remote container runtime socket path...
2026-11-13T20:29:02.776Z testcontainers [TRACE] Resolving host...
2026-11-13T20:29:02.777Z testcontainers [TRACE] Fetching Compose info...
2026-11-13T20:29:02.777Z testcontainers [TRACE] Looking up host IPs...
2026-11-13T20:29:02.782Z testcontainers [TRACE] Initialising clients...
2026-11-13T20:29:02.782Z testcontainers [TRACE] Container runtime info:
{
"node": {
"version": "v24.19.0",
"architecture": "x64",
"platform": "linux"
},
"containerRuntime": {
"host": "localhost",
"hostIps": [
{
"address": "127.0.0.1",
"family": 4
}
],
"remoteSocketPath": "/var/run/docker.sock",
"indexServerAddress": "https://index.docker.io/v1/",
"serverVersion": "29.7.2",
"operatingSystem": "Ubuntu 24.04.4 LTS",
"operatingSystemType": "linux",
"architecture": "x86_64",
"cpus": 4,
"memory": 8054751232,
"runtimes": [
"io.containerd.runc.v2",
"runc"
],
"labels": []
}
}
2026-11-13T20:29:02.782Z testcontainers [DEBUG] Container runtime strategy "UnixSocketStrategy" works
2026-11-13T20:29:02.783Z testcontainers [DEBUG] Checking if image exists "alpine:latest"...
2026-11-13T20:29:02.855Z testcontainers [DEBUG] Checked if image exists "alpine:latest"
2026-11-13T20:29:02.855Z testcontainers [DEBUG] Image "alpine:latest" already exists
2026-11-13T20:29:02.857Z testcontainers [DEBUG] Acquiring lock file "/tmp/testcontainers-node-1000.lock"...
2026-11-13T20:29:02.859Z testcontainers [DEBUG] Acquired lock file "/tmp/testcontainers-node-1000.lock"
2026-11-13T20:29:02.859Z testcontainers [DEBUG] Listing containers...
2026-11-13T20:29:02.881Z testcontainers [DEBUG] Listed containers
2026-11-13T20:29:02.885Z testcontainers [DEBUG] Creating new Reaper for session "30b4719e4c28" with socket path "/var/run/docker.sock"...
2026-11-13T20:29:02.886Z testcontainers [DEBUG] Checking if image exists "testcontainers/ryuk:0.14.0"...
2026-11-13T20:29:02.945Z testcontainers [DEBUG] Checked if image exists "testcontainers/ryuk:0.14.0"
2026-11-13T20:29:02.945Z testcontainers [DEBUG] Image "testcontainers/ryuk:0.14.0" already exists
2026-11-13T20:29:02.946Z testcontainers [DEBUG] Creating container for image "testcontainers/ryuk:0.14.0"...
2026-11-13T20:29:03.054Z testcontainers [DEBUG] [12fc1477fcca] Created container for image "testcontainers/ryuk:0.14.0"
2026-11-13T20:29:03.054Z testcontainers [INFO] [12fc1477fcca] Starting container for image "testcontainers/ryuk:0.14.0"...
2026-11-13T20:29:03.054Z testcontainers [DEBUG] [12fc1477fcca] Starting container...
2026-11-13T20:29:03.322Z testcontainers [DEBUG] [12fc1477fcca] Started container
2026-11-13T20:29:03.322Z testcontainers [INFO] [12fc1477fcca] Started container for image "testcontainers/ryuk:0.14.0"
2026-11-13T20:29:03.326Z testcontainers [DEBUG] [12fc1477fcca] Fetching container logs...
2026-11-13T20:29:03.328Z testcontainers [DEBUG] [12fc1477fcca] Waiting for container to be ready...
2026-11-13T20:29:03.328Z testcontainers [DEBUG] [12fc1477fcca] Waiting for log message "/.*Started.*/"...
2026-11-13T20:29:03.328Z testcontainers [DEBUG] [12fc1477fcca] Fetching container logs...
2026-11-13T20:29:03.334Z testcontainers [DEBUG] [12fc1477fcca] Demuxing stream...
2026-11-13T20:29:03.334Z testcontainers [DEBUG] [12fc1477fcca] Demuxed stream
2026-11-13T20:29:03.336Z testcontainers [DEBUG] [12fc1477fcca] Demuxing stream...
2026-11-13T20:29:03.336Z testcontainers [DEBUG] [12fc1477fcca] Demuxed stream
2026-11-13T20:29:03.618Z testcontainers [DEBUG] [12fc1477fcca] Log wait strategy complete
2026-11-13T20:29:03.626Z testcontainers [INFO] [12fc1477fcca] Container is ready
2026-11-13T20:29:03.626Z testcontainers [DEBUG] [12fc1477fcca] Connecting to Reaper (attempt 1) on "localhost:32817"...
2026-11-13T20:29:03.628Z testcontainers:containers [12fc1477fcca] time=2026-11-13T20:29:03.612Z level=INFO msg=starting connection_timeout=1m0s reconnection_timeout=10s request_timeout=10s shutdown_timeout=10m0s remove_retries=10 retry_offset=-1s changes_retry_interval=1s port=8080 verbose=false
2026-11-13T20:29:03.629Z testcontainers:containers [12fc1477fcca] time=2026-11-13T20:29:03.613Z level=INFO msg=Started address=[::]:8080
2026-11-13T20:29:03.629Z testcontainers:containers [12fc1477fcca] time=2026-11-13T20:29:03.613Z level=INFO msg="client processing started"
2026-11-13T20:29:03.630Z testcontainers [DEBUG] [12fc1477fcca] Connected to Reaper
2026-11-13T20:29:03.630Z testcontainers [DEBUG] Releasing lock file "/tmp/testcontainers-node-1000.lock"...
2026-11-13T20:29:03.631Z testcontainers [DEBUG] Released lock file "/tmp/testcontainers-node-1000.lock"
2026-11-13T20:29:03.634Z testcontainers [DEBUG] Creating container for image "alpine:latest"...
2026-11-13T20:29:03.635Z testcontainers:containers [12fc1477fcca] time=2026-11-13T20:29:03.632Z level=INFO msg="client connected" address=172.17.0.1:49260 clients=1
2026-11-13T20:29:03.636Z testcontainers:containers [12fc1477fcca] time=2026-11-13T20:29:03.633Z level=INFO msg="adding filter" type=label values="[org.testcontainers.session-id=30b4719e4c28]"
2026-11-13T20:29:03.738Z testcontainers [DEBUG] [dbca518416dd] Created container for image "alpine:latest"
2026-11-13T20:29:03.738Z testcontainers [INFO] [dbca518416dd] Starting container for image "alpine:latest"...
2026-11-13T20:29:03.738Z testcontainers [DEBUG] [dbca518416dd] Starting container...
2026-11-13T20:29:03.971Z testcontainers [DEBUG] [dbca518416dd] Started container
2026-11-13T20:29:03.971Z testcontainers [INFO] [dbca518416dd] Started container for image "alpine:latest"
2026-11-13T20:29:03.973Z testcontainers [DEBUG] [dbca518416dd] Fetching container logs...
2026-11-13T20:29:03.974Z testcontainers [DEBUG] [dbca518416dd] Fetching container logs...
2026-11-13T20:29:03.978Z testcontainers [DEBUG] [dbca518416dd] Waiting for container to be ready...
2026-11-13T20:29:03.978Z testcontainers [DEBUG] [dbca518416dd] Waiting for log message "to-stderr"...
2026-11-13T20:29:03.978Z testcontainers [DEBUG] [dbca518416dd] Fetching container logs...
2026-11-13T20:29:03.980Z testcontainers [DEBUG] [dbca518416dd] Demuxing stream...
2026-11-13T20:29:03.980Z testcontainers [DEBUG] [dbca518416dd] Demuxed stream
data: to-stderr
data: to-stdout
2026-11-13T20:29:03.982Z testcontainers [DEBUG] [dbca518416dd] Demuxing stream...
2026-11-13T20:29:03.982Z testcontainers [DEBUG] [dbca518416dd] Demuxed stream
2026-11-13T20:29:03.983Z testcontainers:containers [dbca518416dd] to-stderr
2026-11-13T20:29:03.983Z testcontainers:containers [dbca518416dd] to-stdout
2026-11-13T20:29:03.983Z testcontainers [DEBUG] [dbca518416dd] Demuxing stream...
2026-11-13T20:29:03.983Z testcontainers [DEBUG] [dbca518416dd] Demuxed stream
2026-11-13T20:29:03.983Z testcontainers [DEBUG] [dbca518416dd] Log wait strategy complete
2026-11-13T20:29:03.984Z testcontainers [INFO] [dbca518416dd] Container is ready
Steps to Reproduce
npm install testcontainers- Save the code as
repro.ts. - Run
node repro.ts(Node 24+, for type stripping and await using).
Environment Information
- Operating System: Ubuntu 24.04.4 LTS (x86_64)
- Container runtime and version: Docker Engine 29.7.2
- Node version: v24.19.0
- Test runner and version: None (standalone script)
- Testcontainers version: 12.2.1 (built from main c79a5a56; same code in the published 12.2.1), image alpine:latest
- Last Testcontainers version where this worked, if any: None
Cause
modem.demuxStream(stream, demuxedStream, demuxedStream) passes the same PassThrough as both the stdout and the stderr target, so the label is lost. By contrast, exec passes separate stdout and stderr streams:
Other "err" listeners that never fire
Notes
- Three ways to fix this I can think of:
- only take out
"err"listener in the docs and the library files above so readers don't expect stderr on"err". - keep
"data"for both and add new filter optionsstdoutandstderrtologs(), e.g.container.logs({ stdout: true, stderr: false }). This can leavedemuxStreamalone. - split like
exec(#842): keep the merged stream and add separate stdout and stderr streams, which requires new API.
-
2 and 3 will still need 1 and a docs example for the new option. I'd lean toward 2 because it enables stderr filtering but is smaller than 3. Does that sound right?
-
Related: #1544. Its example text uses
stream.on("err"), and its proposedgetLogs()stdout/stderr option depends on this decision. With 1 alone,getLogs()couldn’t provide stdout/stderr option. -
Happy to take this after my #1544 PR.
-
I used Claude to understand the codebase and search issues. I wrote this issue and will write the code myself.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 2.6k
- Forks
- 287
- Ø Merge
- 3 T. 20 Std.
- Gemergte PRs (30 T.)
- 11
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus testcontainers/testcontainers-node
-
enhancement minor
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
testcontainers/testcontainers-node#1539 ·
Maintainer antworten meist innerhalb von 5 Tagen
-
Let `Wait.forListeningPorts()` wait on specific portsEvtl. vergeben @artbom hat das vor 13 Tagen übernommen. Offenenhancement minor
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
testcontainers/testcontainers-node#1533 ·
Maintainer antworten meist innerhalb von 5 Tagen
-
enhancement minor
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 77/100
testcontainers/testcontainers-node#1531 ·
Maintainer antworten meist innerhalb von 5 Tagen
-
Add the missing builder methods to the `TestContainer` interfaceEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offenenhancement minor
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
testcontainers/testcontainers-node#1529 ·
Maintainer antworten meist innerhalb von 5 Tagen
-
Export the types used in public method signaturesEvtl. vergeben @artbom hat das vor 13 Tagen übernommen. Offenenhancement minor
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
testcontainers/testcontainers-node#1528 ·
Maintainer antworten meist innerhalb von 5 Tagen
Alle Issues in testcontainers/testcontainers-node
Ähnliche Issues
-
area: batch
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
inabagumi/shinju-date#7294 ·
Maintainer antworten meist innerhalb von 1 Tag
-
documentation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
streaming-video-technology-alliance/common-media-library#700 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
vercel-labs/ui#809 ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
KrisCris/village-in-the-shade-guide#75 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bot:ai-assisted component:platform-js status:untriaged
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 74/100
midnightntwrk/platform-js#38 ·