fix(electron): skip single-instance lock in dev to prevent dev server…#1276
fix(electron): skip single-instance lock in dev to prevent dev server…#1276dataCenter430 wants to merge 5 commits intoeigent-ai:mainfrom
Conversation
Wendong-Fan
left a comment
There was a problem hiding this comment.
Thanks @dataCenter430 for the PR. I'm curious what specific use case requires running multiple instances instead of a single instance in dev?
Enabling multi-instance by default can introduce risks, if there's indeed have some usecase for this, would it be better to keep single-instance as the default, and only allow multi-instance when explicitly enabled via an environment variable, e.g. EIGENT_DEV_MULTI_INSTANCE=1?
|
Hi, @Wendong-Fan thanks for your review. Changes:
I really appreciate your review with this and hope this will be merged in codebase. |
|
Hi, @fengju0213 |
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