mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-09 08:21:50 +00:00
fix(desktop): wait for backend exit before reloading on connection-config apply
The apply handler sent SIGTERM then fired a 150 ms setTimeout to reload the renderer. If the backend took longer to shut down the port was still bound when startHermes() ran after reload, causing an "address already in use" failure. Capture the process reference before resetHermesConnection() nulls it, then await the actual exit event. A 5 s SIGKILL fallback ensures the wait never hangs if the backend ignores SIGTERM.
This commit is contained in:
parent
fef04a197e
commit
6feb40e702
1 changed files with 19 additions and 2 deletions
|
|
@ -4076,9 +4076,26 @@ ipcMain.handle('hermes:connection-config:save', async (_event, payload) => {
|
|||
ipcMain.handle('hermes:connection-config:apply', async (_event, payload) => {
|
||||
const config = coerceDesktopConnectionConfig(payload)
|
||||
writeDesktopConnectionConfig(config)
|
||||
resetHermesConnection()
|
||||
setTimeout(() => mainWindow?.reload(), 150)
|
||||
|
||||
// Capture the reference before resetHermesConnection() nulls hermesProcess,
|
||||
// so we can wait for actual exit rather than assuming a fixed delay is enough.
|
||||
const dying = hermesProcess && !hermesProcess.killed ? hermesProcess : null
|
||||
resetHermesConnection()
|
||||
|
||||
if (dying) {
|
||||
await new Promise(resolve => {
|
||||
const timer = setTimeout(() => {
|
||||
try { dying.kill('SIGKILL') } catch {}
|
||||
resolve()
|
||||
}, 5000)
|
||||
dying.once('exit', () => {
|
||||
clearTimeout(timer)
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
mainWindow?.reload()
|
||||
return sanitizeDesktopConnectionConfig(config)
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue