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
@ -6551,6 +6551,12 @@ app.on('before-quit', () => {
|
|||||||
flushDesktopLogBufferSync()
|
flushDesktopLogBufferSync()
|
||||||
closePreviewWatchers()
|
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) {
|
if (hermesProcess && !hermesProcess.killed) {
|
||||||
hermesProcess.kill('SIGTERM')
|
hermesProcess.kill('SIGTERM')
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user