Skip to content

Make blocking stream reads cancellable - #908

Merged
gesellix merged 3 commits into
mainfrom
fix/interruptible-stream-reads
Dec 3, 2026
Merged

gesellix merged 3 commits into
mainfrom
fix/interruptible-stream-reads

Conversation

@gesellix

@gesellix gesellix commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Attach/exec/log streams could hang for minutes on Windows named pipes, even with a timeout configured.

Cause

consumeStream and both consumeFrames flows called the blocking hasNext()/readNext() directly inside flow {}. 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 runInterruptible on Dispatchers.IO, so cancellation interrupts the blocked thread. FrameReader/JsonChunksReader already 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 default AsynchronousFileChannel-based implementation already honored interrupts.

Tests

  • WCOW (Docker Desktop, Windows containers), with both named pipe implementations: ContainerApiIntegrationTest attach (interactive/non-interactive), logs; ExecApiIntegrationTest (interactive/non-interactive).
  • docker-client's attach (interactive) and exec (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

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>
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

0 tests   - 248   0 ✅  - 234   0s ⏱️ - 1m 40s
0 suites  -  32   0 💤  -  14 
0 files    -  32   0 ❌ ±  0 

Results for commit 96669de. ± Comparison against base commit fae1361.

♻️ This comment has been updated with latest results.

gesellix and others added 2 commits December 3, 2026 23:12
- 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>
@gesellix
gesellix merged commit 0114644 into main Dec 3, 2026
4 of 8 checks passed
@gesellix
gesellix deleted the fix/interruptible-stream-reads branch December 3, 2026 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant