mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-21 10:22:18 +00:00
fix(desktop): dispose open PTY sessions in before-quit handler
The `before-quit` handler tears down the bootstrap controller, preview watchers, and the Python backend but never disposes live PTY sessions. When `app.quit()` proceeds to `FreeEnvironment()`, node-pty's `ThreadSafeFunction::CallJS` callback fires on a half-torn-down environment, throws a C++ exception that can no longer be caught, and the process aborts (microsoft/node-pty#904). Iterate `terminalSessions` and call `disposeTerminalSession()` (which already calls `pty.kill()` + deletes the map entry) before killing the backend, so the ThreadSafeFunctions are removed before teardown begins. Closes #48335
This commit is contained in:
parent
2f7c4858a7
commit
92e6d8c858
1 changed files with 6 additions and 0 deletions
|
|
@ -6551,6 +6551,12 @@ app.on('before-quit', () => {
|
|||
flushDesktopLogBufferSync()
|
||||
closePreviewWatchers()
|
||||
|
||||
// Kill open PTYs before environment teardown to avoid the node-pty#904
|
||||
// ThreadSafeFunction SIGABRT race.
|
||||
for (const id of [...terminalSessions.keys()]) {
|
||||
disposeTerminalSession(id)
|
||||
}
|
||||
|
||||
if (hermesProcess && !hermesProcess.killed) {
|
||||
hermesProcess.kill('SIGTERM')
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue