You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: replace 10ms delay with proper readline event synchronization
The previous approach used a 10ms delay to allow readline interfaces to
process buffered data after process exit. This was a timing-based workaround
that wasn't truly correct-by-construction.
## Problem
When a process exits, there's a race between:
1. Process 'exit' event
2. Readline 'close' events (stdout and stderr)
For commands like 'grep | head', the stdout stream closes early (when head
exits), which triggers readline 'close' BEFORE the process 'exit' event.
The 10ms delay hoped to bridge this gap, but it's not deterministic.
## Solution
Wait for all three events concurrently using Promise.all():
- exitCode (process exit)
- stdoutClosed (readline finished processing stdout)
- stderrClosed (readline finished processing stderr)
This ensures we never return results before readline has finished processing
all buffered data, without relying on arbitrary timing delays.
## Testing
- All 955 unit tests pass
- All bash integration tests pass, including the grep|head regression test
- Both local and SSH runtime tests pass
- No timing-based workarounds
---
_Generated with `cmux`_
0 commit comments