From 6292f1c7f2fa7c1f7d3bd9ec3c6c599d7f1b4b01 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Wed, 23 Nov 2022 16:46:04 +0800 Subject: [PATCH] fix broken requestSingleInstanceLock in MAS --- public/electron.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/public/electron.js b/public/electron.js index caca2eee..0d1c9af8 100644 --- a/public/electron.js +++ b/public/electron.js @@ -149,7 +149,12 @@ function parseCliArgs(rawArgv = process.argv) { const argv = parseCliArgs(); -if (!argv.allowMultipleInstances && !app.requestSingleInstanceLock()) { +function safeRequestSingleInstanceLock() { + if (process.mas) return true; // todo remove when fixed https://github.com/electron/electron/issues/35540 + return app.requestSingleInstanceLock(); +} + +if (!argv.allowMultipleInstances && !safeRequestSingleInstanceLock()) { app.quit(); } else { // On macOS, the system enforces single instance automatically when users try to open a second instance of your app in Finder, and the open-file and open-url events will be emitted for that.