fix(desktop): skip ensureBackend after profile-delete teardown to prevent respawn loop (#52279) - #52301
Conversation
…vent respawn loop
When the renderer sends a DELETE /api/profiles/{name} request, the IPC
handler tears down the profile's pool backend (or primary backend) via
prepareProfileDeleteRequest. However, the very next line calls
ensureBackend(profile), which spawns a fresh pool backend for the just-
deleted profile. The new backend's startup path calls ensure_hermes_home(),
which recreates the profile directory — defeating the deletion and leaving
the process as a zombie.
On the next Desktop restart the cycle repeats: the profile directory exists,
the Desktop spawns a backend, the backend recreates the directory after
deletion, and PIDs accumulate indefinitely.
Fix: make prepareProfileDeleteRequest return the torn-down profile name.
The IPC handler uses this to route the DELETE to the primary backend
instead of spawning a new pool backend for the deleted profile.
Fixes NousResearch#52279
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
Well-scoped bug fix for a respawn loop in profile deletion. The fix correctly routes profile-delete requests to the primary backend instead of spawning a fresh pool backend. Good documentation in code comments explaining the root cause. Dedicated test file with structural tests verifies the fix.
Changes:
apps/desktop/electron/main.cjs: Returns torn-down profile name fromprepareProfileDeleteRequest, routes to primary backend after deleteapps/desktop/electron/profile-delete-respawn.test.cjs: New test file with structural tests
Clean, minimal fix with clear root cause analysis. LGTM.
Reviewed by Hermes Agent
|
Superseded by #57329, which carries your commit as-is (cherry-picked, authorship + Your diagnosis was exactly right: a pool backend spawned for the just-deleted profile calls |
What does this PR do?
Fixes a respawn loop where deleting a non-default profile via the Desktop UI causes the profile directory to be recreated indefinitely, accumulating zombie backend processes.
Related Issue
Fixes #52279
Type of Change
Changes Made
apps/desktop/electron/main.cjs: MakeprepareProfileDeleteRequestreturn the torn-down profile name. In thehermes:apiIPC handler, use this return value to route the DELETE request to the primary backend instead of spawning a fresh pool backend for the just-deleted profile.apps/desktop/electron/profile-delete-respawn.test.cjs: Structural tests verifyingprepareProfileDeleteRequestreturns the profile name and the IPC handler uses it to skipensureBackend.How to Test
hermes profile create test-profilehermes dashboard --profile test-profileprocesses remain (ps aux | grep "hermes.*dashboard.*profile")node --test apps/desktop/electron/profile-delete-respawn.test.cjs— both tests should passChecklist
Code
fix(scope):,feat(scope):, etc.)node --test apps/desktop/electron/profile-delete-respawn.test.cjsand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/ACode Intelligence
apps/desktop/electron/main.cjs(prepareProfileDeleteRequest,ensureBackend,hermes:apihandler)teardownPoolBackendAndWaitlifecycle,ensure_hermes_home()directory creation,backendPoolmanagement