-
Notifications
You must be signed in to change notification settings - Fork 15k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: app.requestSingleInstanceLock() returns true on second start (Windows) #35680
Comments
if (additionalData) {
additionalData.otherPid = process.pid;
}
Also see #34279, though it hasn't been maintained. |
I read the code about adding message passing to the single-instance-lock handler. Note that the issue here is that the second process was able to get the single-instance-lock -- our code never releases it. That's my core problem. The call works as expected on macOS (meaning that the second instance fails to get the lock), but doesn't on Windows (the second instance succeeds at getting the lock when it I would expect it not to). The use of |
@ericpromislow I noticed you're using v18.0.3 - could you please try using 18.3.0 or higher? We fixed fairly significant issues with requestSingleInstanceLock in both 18.2.0 and 18.3.0, bumping up to 18.3.0 may resolve this issue for you: https://www.electronjs.org/releases/stable?version=18&page=2#18.3.0 |
Bumping to 18.3.6 didn't fix this issue on Windows. |
Are there any updates on this? While I haven't gone into it as far as @ericpromislow, I'm seeing What is the likelihood that someone in the know will be able to look at this? I've read some of the electron and chromium code around this, and I'm not sure I could implement a fix without a lot of effort, given I'm not familiar with C++... |
I wonder how much of it is due to the |
I did some investigation on Linux with
I don't think so... @ericpromislow do you know? |
I'm pretty sure it did work, but don't remember which version it broke on (I could always investigate...) |
So I had time to do some more digging and I figured out that the problem was on our side. Basically we were calling So, this issue can be closed. However, I feel like this wouldn't have happened if electron's design around application name was slightly different. My understanding is that there are two versions of the application name: the "pretty" version ("Rancher Desktop" in our case) and the "programmatic" version ("rancher-desktop"). We need to set the pretty version because that is what appears in the title bar. But it seems strange that the pretty name is the one that is used to determine the directory where all of the electron/chromium stuff is cached (i.e. More feedback: I had a bear of a time trying to move the location of the electron/chromium cache directory. I wasn't actually successful in the end; I left it at its default value of Also, why is the default location for cache files under Sorry for all the criticisms. Maybe you guys are aware of them, and maybe they've been fixed since the version of electron we are using. But I figured it wouldn't hurt to note them here. |
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment! |
This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue. |
Preflight Checklist
Electron Version
18.0.3
What operating system are you using?
Windows
Operating System Version
Windows 10 Pro 19043.1889
What arch are you using?
x64
Last Known Working Electron version
n/a
Expected Behavior
I've "compiled" our app into a standalone Windows executable. When I click on the app's icon the first time,
I expect the app to run. When I click on the icon the second time, I want to see the first instance's window,
even if it was minimized.
I do this through the following code:
Actual Behavior
Here's the gist of the code, running in the main process's main TS file:
Both instances succeed at calling
Electron.app.requestSingleInstanceLock()
The first instance gets a
second-instance
event, but theadditionalInfo
field is empty. When I saw thatthe call to
requestSingleInstanceLock()
was always succeeding, I was hoping that if I passed an object torequestSingleInstanceLock()
it would be passed asadditionalInfo
to thesecond-instance
event handler, but that isn't happening.Testcase Gist URL
Nope
Additional Information
Here's how to repro:
Running the installer takes a few minutes to show up.
Then double-click on the icon, and allow it to start up. Minimize the window.
Then double-click on the icon again. It should bring up the window for the first instance, but instead
it creates a new window and emits a message that a port is already in use.
There's a
lockfile
in~/AppData/Roaming/rancher-desktop
, but it doesn't seem to be working the same way theSingleton*
files in~/L/AppSupp/r-d
do for macOS.The text was updated successfully, but these errors were encountered: