electron
electron copied to clipboard
[Bug]: requestSingleInstanceLock({ myEmptyArray: [] }) - additionalData is { myEmptyArray: [] } on Linux ✅ but null on Windows ❌
Preflight Checklist
- [X] I have read the Contributing Guidelines for this project.
- [X] I agree to follow the Code of Conduct that this project adheres to.
- [X] I have searched the issue tracker for a bug report that matches the one I want to file, without success.
Electron Version
27.1.0
Operating System Version
Windows 11 Home | Linux x86_64
What arch are you using?
x64
Last Known Working Electron version
Not sure
Expected Behavior
Windows should behave like Linux and prints
// console.log(additionalData);
{ myEmptyArray: [] }
Actual Behavior
On Windows, we get
// console.log(additionalData);
null
Testcase Gist URL
https://gist.github.com/6b77dd48dc95b711267c62fb9cd5c939
Edit: added further instructions in a separate comment below.
Additional Information
In addition to the gist above, I've created a minimal reproducible example GitHub repository.
The example uses the electron-quickstart-template.
The feature in question is app#apprequestsingleinstancelockadditionaldata.
The example adds the code in this commit to the template:
// At the very top, after imports
if (!app.requestSingleInstanceLock({ myEmptyArray: [] })) {
app.quit();
process.exit(0);
}
app.on('second-instance', (_event, _commandLine, _workingDirectory, additionalData) => {
console.log('second-instance additionalData:', additionalData);
});
If the array isn't empty (e.g. [1] or [''] instead of []), Windows behaves as expected similar to Linux.
Adding further results when using the Electron Fiddle gist (Electron v27.0.4).
Steps:
- Paste https://gist.github.com/6b77dd48dc95b711267c62fb9cd5c939 and "Load Fiddle"
- Click "Run", minimize electron app window
- Right click on the "Stop" button (previously the "Run" button from step 2) and select "Run Fiddle" from the dropdown menu to run a second instance:
Linux results:
Windows results:
This is affected by key order:
// This gets `null`:
app.requestSingleInstanceLock({
argv: [],
nonsense: [1],
});
// whereas this gets through:
app.requestSingleInstanceLock({
nonsense: [1],
argv: [],
});
Also, odd-numbered length keys, and keys born in the year of the Snake appear to be unaffected:
{ a: [] } -> { a: [] }
{ b: [] } -> { b: [] }
{ m: [] } -> { m: [] }
{ aa: [] } -> null
{ ab: [] } -> null
{ am: [] } -> null
{ ba: [] } -> null
{ bb: [] } -> null
{ bm: [] } -> null
{ ma: [] } -> null
{ mb: [] } -> null
{ mm: [] } -> null
{ aaa: [] } -> { aaa: [] }
{ aab: [] } -> { aab: [] }
{ aam: [] } -> { aam: [] }
{ aba: [] } -> { aba: [] }
{ abb: [] } -> { abb: [] }
{ abm: [] } -> { abm: [] }
{ ama: [] } -> { ama: [] }
{ amb: [] } -> { amb: [] }
{ amm: [] } -> { amm: [] }
{ baa: [] } -> { baa: [] }
{ bab: [] } -> { bab: [] }
{ bam: [] } -> { bam: [] }
{ bba: [] } -> { bba: [] }
{ bbb: [] } -> { bbb: [] }
{ bbm: [] } -> { bbm: [] }
{ bma: [] } -> { bma: [] }
{ bmb: [] } -> { bmb: [] }
{ bmm: [] } -> { bmm: [] }
{ maa: [] } -> { maa: [] }
{ mab: [] } -> { mab: [] }
{ mam: [] } -> { mam: [] }
{ mba: [] } -> { mba: [] }
{ mbb: [] } -> { mbb: [] }
{ mbm: [] } -> { mbm: [] }
{ mma: [] } -> { mma: [] }
{ mmb: [] } -> { mmb: [] }
{ mmm: [] } -> { mmm: [] }
{ aaaa: [] } -> null
{ aaab: [] } -> null
...
{ aaaaa: [] } -> { aaaaa: [] }
...
{ mamba: [] } -> { mamba: [] }
...
Personally I think we should explore an astrological explanation for this behavior.
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!
bump