question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Electron: investigate to use `requestSingleInstanceLock()` API

See original GitHub issue

Currently VSCode is implementing it’s own solution for preventing a second instance from starting. Electron provides API to do the same but there are differences: https://github.com/electron/electron/blob/7-1-x/docs/api/app.md#apprequestsingleinstancelock

Things we need:

[1] code --status will print information about the active window in the first instance to the console of the second instance and thus requires access to the workspace, including remote scenarios.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

3reactions
deepak1556commented, Jul 7, 2022

Adding @bpasero comments about the benefits from using the API:

  • Might help mitigate multiple dock icon on macOS
  • Performance gain (needs to be measured) if runtime handles the communication channel and exit of the new instance
  • Handle connection between elevated and non-elevated instances.
1reaction
deepak1556commented, Jan 2, 2023

Good catch, maybe the API can provide an option to allow this default behavior or abort and surface as error to users.

app.requestSingleInstanceLock{{allowAdminLaunch: <boolean>})
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the electron.app.on function in electron - Snyk
To help you get started, we've selected a few electron.app.on examples, based on ... requestSingleInstanceLock() if (!gotTheLock) { app.quit() } else ...
Read more >
How to Code a Desktop App Using Electron
Let's talk about Electron, examine what can it be used for, and how to build a desktop app with it.
Read more >
app | Electron
Control your application's event lifecycle.
Read more >
Interop's Labyrinth: Sharing Code Between Web & Electron ...
Things aren't always what they seem in this place, so you can't take anything for ... and access to exciting new APIs like...
Read more >
How to prevent multiple instances in Electron - Stack Overflow
There is a new API now: requestSingleInstanceLock const { app } = require('electron') let myWindow = null const gotTheLock = app.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found