Repository navigation
Make blocking stream reads cancellable - #908
Merged
Merged
Conversation
consumeStream and both consumeFrames flows called the blocking hasNext()/readNext() directly. Coroutine cancellation (withTimeout, Cancellable.cancel()) only takes effect at a suspension point, which never comes while a native read blocks, so attach/exec timeouts were not enforced and could hang for minutes on Windows named pipes. Run the blocking calls via runInterruptible on Dispatchers.IO, so that cancellation interrupts the blocked thread. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
- systemVersion: accept any API version >= 1.42 instead of a list that needs an update with every Docker release (failed on all Windows CI runs) - containerArchiveInfoGetAndPut: wait for the mkdir exec to finish before stopping the container, it could be stopped before the directory existed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Named pipe fixes for WCOW (docker-client/docker-filesocket#526) and UnixSocket timeout/half-close delegation (docker-client/docker-filesocket#527). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Attach/exec/log streams could hang for minutes on Windows named pipes, even with a timeout configured.
Cause
consumeStreamand bothconsumeFramesflows called the blockinghasNext()/readNext()directly insideflow {}. Coroutine cancellation (withTimeout,Cancellable.cancel()) only takes effect at a suspension point, which never comes while a native read blocks. So the timeout was never enforced.Change
The blocking calls now run via
runInterruptibleonDispatchers.IO, so cancellation interrupts the blocked thread.FrameReader/JsonChunksReaderalready check the interrupted flag, so this is how the design was meant to work.The socket side has to honor interrupts too. For the JNI named pipe implementation, that's part of docker-client/docker-filesocket#526 (released as
2.0.202612032258); the defaultAsynchronousFileChannel-based implementation already honored interrupts.Tests
ContainerApiIntegrationTestattach (interactive/non-interactive), logs;ExecApiIntegrationTest(interactive/non-interactive).attach (interactive)andexec (interactive)on WCOW against this change: they now fail fast on a mismatch instead of hanging, and pass together with the docker-client test fixes.🤖 Generated with Claude Code