fix(terminal): fix race condition preventing onData listeners from receiving data when set immediately after construction#37
Conversation
WalkthroughThe PTY read loop startup in Terminal was deferred to a microtask (queueMicrotask) so constructors complete before reading begins. Two integration tests were added to validate immediate onData wiring and a conditional sync test with cross-platform timeouts. Changes
Sequence Diagram(s)(omitted — changes are limited to deferring a read loop start and added tests; no multi-component sequential flow requiring visualization) Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/terminal.integration.test.ts`:
- Around line 503-533: The test creates a Terminal instance but never registers
it with the shared terminals array used by the global afterEach cleanup; after
constructing the terminal (const terminal = new Terminal(cmd, args)) add
terminals.push(terminal) so the test's Terminal is cleaned up on exceptions via
the existing afterEach logic (referencing the terminals array and the Terminal
instance variable).
… calls Instead of calling terminal.kill() directly in the 'Terminal sync tests', push the terminal to the terminals array for automatic cleanup in afterEach. This ensures consistent cleanup behavior across all integration tests.
Closes #35
Summary
Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.