fix(pty): pty session handle leak by kikuchan · Pull Request #15599 · anomalyco/opencode
Issue for this PR
Closes #15592
Type of change
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
What does this PR do?
Ensure to call session.process.kill() on ptyProcess.onExit to clean up PTY sessions properly.
How did you verify your code works?
(edited) Added an automated test for the issue.
Before the patch:
onExit() -> publish Exited event -> state().delete(id) -> cannot remove() anymore.
After the patch:
onExit() -> publish Exited event -> session.process.kill() -> publish Delete event
Note:
onExit() and remove() are called twice at most, so I have to move state().delete(id) to above and add session.info.status === 'exited' check.
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR