Skip to content
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

meteor desktop 2.2.5 + single instance on + electron 4+ fails to start #274

Open
dorian-coygo opened this issue May 31, 2020 · 0 comments · May be fixed by #275
Open

meteor desktop 2.2.5 + single instance on + electron 4+ fails to start #274

dorian-coygo opened this issue May 31, 2020 · 0 comments · May be fixed by #275

Comments

@dorian-coygo
Copy link

dorian-coygo commented May 31, 2020

Setup:
package.json

meteor-desktop: 2.2.5
electron: 4.0.0

.desktop/settings

singleInstance: true

command:

meteor npm run desktop -- run 127.0.0.1:3000

Expected result:
The app to successfully build

Current result:

debug: [main] skeleton version 2.2.5
verbose: [main] setting single instance mode
App threw an error during load
TypeError: app.makeSingleInstance is not a function
    at App.applySingleInstance (/Users/dkersch/Development/coygo/webapp/.meteor/desktop-build/app/app.js:131:42)
    at new App (/Users/dkersch/Development/coygo/webapp/.meteor/desktop-build/app/app.js:63:14)
    at Object.<anonymous> (/Users/dkersch/Development/coygo/webapp/.meteor/desktop-build/app/app.js:731:25)
    at Module._compile (internal/modules/cjs/loader.js:786:30)
    at Object.extWrap (/Users/dkersch/Development/coygo/webapp/.meteor/desktop-build/node_modules/reify/node/compile-hook.js:53:7)
    at Object.extManager (/Users/dkersch/Development/coygo/webapp/.meteor/desktop-build/node_modules/reify/node/compile-hook.js:19:12)
    at Object.manager [as .js] (/Users/dkersch/Development/coygo/webapp/.meteor/desktop-build/node_modules/reify/node/wrapper.js:108:20)
    at Module.load (internal/modules/cjs/loader.js:645:32)
    at Function.Module._load (internal/modules/cjs/loader.js:560:12)
    at Module.require (internal/modules/cjs/loader.js:685:19)

Looks like makeSingleInstance() was deprecated in 4.0

Issue in skeleton code.

Potential workaround: singleInstance: false

Potential fix for everyone (briefly tested on my fork):

if (semver.lt(process.versions.electron, '4.0.0')) { //https://www.electronjs.org/docs/all#appmakesingleinstance
    const isSecondInstance = app.makeSingleInstance(() => {
        // Someone tried to run a second instance, we should focus our window.
        if (this.window) {
            if (this.window.isMinimized()) {
                this.window.restore();
            }
            this.window.focus();
        }
    });
} else {
    app.requestSingleInstanceLock()
    const isSecondInstance = app.on('second-instance', () => {
        // Someone tried to run a second instance, we should focus our window.
        if (this.window) {
            if (this.window.isMinimized()) {
                this.window.restore();
            }
            this.window.focus();
        }
            this.l.warn('current instance was terminated because another instance is running');
            app.quit();
    });
}
@dorian-coygo dorian-coygo linked a pull request May 31, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant