fix(desktop): wait for backend exit before reloading on connection-config apply - #38289
Closed
AhmetArif0 wants to merge 1 commit into
Closed
fix(desktop): wait for backend exit before reloading on connection-config apply#38289AhmetArif0 wants to merge 1 commit into
AhmetArif0 wants to merge 1 commit into
Conversation
…nfig 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.
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
hermes:connection-config:applycalledresetHermesConnection()(which sends SIGTERM and immediately nullshermesProcess), then used a hard-codedsetTimeout(() => mainWindow?.reload(), 150)to trigger the renderer reload.150 ms is an arbitrary delay that doesn't track actual process shutdown. If the Python backend takes longer to terminate (signal handler, file-lock release, cleanup code), the renderer reloads and
startHermes()tries to bind the same port while the old process is still alive — resulting in an "address already in use" connection failure.Fix
Capture the process reference before
resetHermesConnection()nulls it, then await the realexitevent:Test plan