Fix container exec output truncation#1381
Open
cristianrgreco wants to merge 1 commit into
Open
Conversation
DockerContainerClient.exec() resolved as soon as the raw multiplexed stream emitted "end", then immediately read the captured chunk arrays. Those arrays are filled by "data" handlers on the demuxed stdout/stderr PassThroughs, which can still be flushing buffered frames at that point, so output/stdout/stderr could be returned truncated. End the demuxed PassThroughs once the raw stream ends and await their completion before reading the chunks. Adds a deterministic regression test reproducing the flush race. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
✅ Deploy Preview for testcontainers-node ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Summary
DockerContainerClient.exec()resolved as soon as the raw multiplexed stream emitted"end", then immediately read the captured chunk arrays. Those arrays are filled by"data"handlers on the demuxed stdout/stderrPassThroughs, which can still be flushing buffered frames at that point — sooutput/stdout/stderrcould be returned truncated under load.The fix ends the demuxed
PassThroughs once the raw stream ends and awaits their completion (stream/promisesfinished()) before reading the chunks.Verification
docker-container-client.test.ts) that reproduces the flush race with a corkedPassThrough(no Docker required).npm ci&&npx vitest run packages/testcontainers/src/container-runtime/clients/container/docker-container-client.test.ts→ 1 passednpm run check-compiles→ clean ·npm run lint→ cleanTest results
1 new test passing; red-green evidence captured above.
Not breaking
Internal behaviour fix to an existing method; public API and return shape (
{ output, stdout, stderr, exitCode }) unchanged. No consumer-visible signature change.🤖 Generated with Claude Code