fix(electron): skip single-instance lock in dev to prevent dev server…#1276
Open
dataCenter430 wants to merge 1 commit intoeigent-ai:mainfrom
Open
fix(electron): skip single-instance lock in dev to prevent dev server…#1276dataCenter430 wants to merge 1 commit intoeigent-ai:mainfrom
dataCenter430 wants to merge 1 commit intoeigent-ai:mainfrom
Conversation
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.
Closes: #1260
Related Issue
as soon as the main process runs, it calls
requestSingleInstanceLock(). If it returnsfalse, the process callsapp.quit()andprocess.exit(0).when run the app via the dev server(
npm run dev), Vite starts the dev server and then starts the Electron main process(often as a child). If you start a second instance (npm run devagain, or launch the app again), that second main process fails to get the lock and exits immediately. The dev tooling (e.g. vite-plugin-electron) sees that child process exit and can treat it as "Electron exited," so the second dev server can shut down or behave oddly.So the report that "the dev server can exit when a second instance starts" is correct.
Description
Single-instance is now enforced only when not running under the Vite dev server:
The process only quits when it doesn't get the lock and it's not in dev:
VITE_DEV_SERVER_URL(already set by the Vite dev server) to detect dev.VITE_DEV_SERVER_URLis set, the earlyapp.quit()/process.exit(0)is skipped, so the second instance in dev does not exit and its dev server stays up.setupSingleInstanceLock()In dev we skip single-instance setup entirely:
VITE_DEV_SERVER_URLis set,setupSingleInstanceLock()returns without callingrequestSingleInstanceLock()orapp.quit(), so no second-instance handling and no quit in dev.Result
second-instance.What is the purpose of this pull request?
Contribution Guidelines Acknowledgement