Skip to content

fix(sdks): read stdout and stderr concurrently to prevent deadlock#296

Merged
DorianZheng merged 1 commit intomainfrom
fix/concurrent-stream-reads
Feb 24, 2026
Merged

fix(sdks): read stdout and stderr concurrently to prevent deadlock#296
DorianZheng merged 1 commit intomainfrom
fix/concurrent-stream-reads

Conversation

@DorianZheng
Copy link
Copy Markdown
Member

Summary

  • Problem: Sequential reads of stdout then stderr can deadlock when a child process fills one pipe buffer (~64KB) while the reader is blocked on the other pipe
  • Fix: Read both streams concurrently using asyncio.gather (Python) and Promise.all (Node.js)
  • Tests: Added TestSimpleBoxConcurrentStreams and TestSyncSimpleBoxConcurrentStreams test classes

Test plan

  • Verify Python async exec reads stdout/stderr concurrently via asyncio.gather
  • Verify Python sync exec uses async internals with concurrent reads
  • Verify Node.js exec reads stdout/stderr concurrently via Promise.all
  • Run new concurrent stream test cases

Sequential reads of stdout then stderr (or vice versa) can deadlock
when a process writes enough to fill one pipe buffer while the reader
is blocked waiting on the other. Switch to concurrent reads using
asyncio.gather (Python) and Promise.all (Node.js).
@DorianZheng DorianZheng merged commit 7027dca into main Feb 24, 2026
25 checks passed
@DorianZheng DorianZheng deleted the fix/concurrent-stream-reads branch February 24, 2026 10:19
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