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
Get response back from single instance event when using app.requestSingleInstanceLock();
?
#20942
Comments
Can you provide a concrete and realistic example of why this feature would be needed? |
Make my second process exit with an exit code = 1 if the main process failed to process the |
Another concrete example I have is argument parsing: I want to do it in my single instance process on |
I think this is doable now that #30891 has been merged. |
Actually this issue is fixed by #31460! Nice :) |
Preflight Checklist
Problem Description
IIUC, when using the
app.requestSingleInstanceLock();
function in our electron main process, when it returnsfalse
we would usually exit the second created process, since the event will be forwarded to the first instance. My issue here is that when exiting the second process, I may want to get feedback from the main instance to know what exit code to return with. Say I wanted to open a resource but it failed, I would like my second process to exit with code != 0. Maybe a CLI argument passed was bogus as well, which case I'd like to exit with code != 0 again.Proposed Solution
Since it would be weird to change the return type of
app.requestSingleInstanceLock()
, maybe add a newapp.waitSingleInstanceResponse()
that would return a promise with the value set from a new callback function in thesecond-instance
event:event.setResponse(data)
. Data type is left to implementers to decide what is easier/better. String is fine with me, or serialization could be done by the framework, I don't know what's best.Alternatives Considered
I would have liked to tap into any already involved IPC mechanism used for that feature, but I don't know where to look for that, and it feels a bit hacky IMO.
Additional Information
This new flow would allow to put most argument parsing into the main single instance process, and avoid thinking about how to break the processing in the temporary second process and then maybe duplicate parsing again in the main instance. Please tell me if I just approach the issue from the wrong angle as well.
The text was updated successfully, but these errors were encountered: