electron: app.requestSingleInstanceLock doesnt work for signed mas builds (Mac App Store)

  • Output of node_modules/.bin/electron --version: 3.0.10
  • Operating System (Platform and Version): MacOS Mojave 10.14.1

Expected Behavior Following code in index.js should not quit app:

let mainInstance = app.requestSingleInstanceLock()
if (!mainInstance) {
  app.quit()
}

Actual behavior App quits.

Additional Information This problem does not occur for unsigned mas builds, only for signed.

@sethlu

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 16
  • Comments: 17 (4 by maintainers)

Commits related to this issue

Most upvoted comments

@Slapbox you can use

const isMas = process.mas === true

to detect mas builds

Had the same issue that Apple rejected due to the reason “App quits on launch”.

Not the best practice, but used process.platform in order to run app.requestSingleInstanceLock() only on other platforms but Mac. Which of course fixed the problem, and Apple approved the app.

It wasn’t worth the stress and time to make it work for Mac on my end since the OS already doesn’t let users run the app more than once. And starting the app via command line is tricky for ordinary users anyway.

But in the long term, hopefully this issue gets fixed so app.requestSingleInstanceLock() plays nicely with the MAS build.

Ultimately, my solution was to add <key>LSMultipleInstancesProhibited</key> to the plist, tested in mas, it worked as expected

Same as this #15304