electron / forge

:electron: A complete tool for building and publishing Electron applications
https://electronforge.io
MIT License
6.45k stars 513 forks source link

Upon running `electron-forge make` on target `dmg` TypeError: Cannot read property 'call' of undefined #236

Closed jfrux closed 7 years ago

jfrux commented 7 years ago

Please describe your issue: After successfully packaging, and testing my app, I run electron-forge make for target dmg and I get the error found below. My question is, are these commonly errors in my own code-base or is this something with electron package?

*Console output when you run electron-forge with the environment variable `DEBUG=electron-forge:`. (Instructions on how to do so here). Please include the stack trace if one exists.**

Packaging Electron project.
  electron-forge:lifecycle Process Started: Preparing to Package Application for arch: x64 +0ms
  electron-forge:project-resolver searching for project in: /Users/joshua/Projects/my-electron-app/tmp/package_task-tmp_path-H3Df5Eqo.tmp +1ms
  electron-forge:project-resolver electron-forge compatible package.json found in /Users/joshua/Projects/my-electron-app/tmp/package_task-tmp_path-H3Df5Eqo.tmp/package.json +3ms
  electron-forge:hook could not find hook: generateAssets +10ms
  electron-forge:hook could not find hook: prePackage +1ms
  electron-forge:packager packaging with options { asar: false,
  overwrite: true,
  name: 'My App',
  appCopyright: 'Copyright (c) 2017 My App',
  versionString: 
   { CompanyName: 'My Company',
     FileDescription: 'My App',
     ProductName: 'My App',
     InternalName: 'My App' },
  protocols: [ { name: 'My App Universal', schemes: [Object] } ],
  protocol: [ 'whatever' ],
  protocolName: 'My App Universal',
  icon: 'assets/icons/my-app',
  afterCopy: [ [Function], [Function], [Function], [Function] ],
  afterExtract: [],
  dir: '/Users/joshua/Projects/my-electron-app/tmp/package_task-tmp_path-H3Df5Eqo.tmp',
  arch: 'x64',
  platform: 'darwin',
  out: 'electron-out',
  electronVersion: '1.6.8',
  quiet: true } +0ms
  electron-forge:lifecycle Process Succeeded: Preparing to Package Application for arch: x64 +3s
  electron-forge:lifecycle Process Started: Compiling Application +1ms
  electron-forge:lifecycle Process Succeeded: Compiling Application +2s
  electron-forge:lifecycle Process Started: Preparing native dependencies +1ms
  electron-forge:lifecycle Process Succeeded: Preparing native dependencies +27ms
  electron-forge:lifecycle Process Started: Packaging Application +0ms
  electron-forge:hook could not find hook: postPackage +948ms
  electron-forge:lifecycle Process Succeeded: Packaging Application +0ms
Making Electron project.
  electron-forge:project-resolver searching for project in: /Users/joshua/Projects/my-electron-app +254ms
  electron-forge:project-resolver electron-forge compatible package.json found in /Users/joshua/Projects/my-electron-app/package.json +1ms
  electron-forge:require-search searching [ '../makers/darwin/dmg.js',
  '../makers/generic/dmg.js',
  'electron-forge-maker-dmg',
  'dmg',
  '/Users/joshua/Projects/my-electron-app/dmg',
  '/Users/joshua/Projects/my-electron-app/node_modules/dmg',
  '/Users/joshua/Projects/my-electron-app/node_modules/electron-forge/dist/makers/darwin/dmg.js',
  '/Users/joshua/Projects/my-electron-app/node_modules/electron-forge/dist/makers/generic/dmg.js',
  '/Users/joshua/Projects/my-electron-app/node_modules/electron-forge/dist/api/electron-forge-maker-dmg',
  '/Users/joshua/Projects/my-electron-app/node_modules/electron-forge/dist/api/dmg',
  '/Users/joshua/Projects/my-electron-app/dmg',
  '/Users/joshua/Projects/my-electron-app/node_modules/dmg',
  '/Users/joshua/Projects/my-electron-app/node_modules/electron-forge/dist/api/makers/darwin/dmg.js',
  '/Users/joshua/Projects/my-electron-app/node_modules/electron-forge/dist/api/makers/generic/dmg.js',
  '/Users/joshua/Projects/my-electron-app/node_modules/electron-forge/dist/api/node_modules/electron-forge-maker-dmg',
  '/Users/joshua/Projects/my-electron-app/node_modules/electron-forge/dist/api/node_modules/dmg',
  '/Users/joshua/Projects/my-electron-app/dmg',
  '/Users/joshua/Projects/my-electron-app/node_modules/dmg' ] relative to /Users/joshua/Projects/my-electron-app/node_modules/electron-forge/dist/api +8ms
  electron-forge:require-search testing ../makers/darwin/dmg.js +1ms
  electron-forge:hook could not find hook: preMake +4ms
Cannot read property 'call' of undefined
TypeError: Cannot read property 'call' of undefined
    at CpFileError.get (/Users/joshua/Projects/my-electron-app/node_modules/nested-error-stacks/index.js:22:51)
    at _callee2$ (/Users/joshua/Projects/my-electron-app/node_modules/electron-forge/dist/api/make.js:376:94)
    at tryCatch (/Users/joshua/Projects/my-electron-app/node_modules/regenerator-runtime/runtime.js:65:40)
    at Generator.invoke [as _invoke] (/Users/joshua/Projects/my-electron-app/node_modules/regenerator-runtime/runtime.js:303:22)
    at Generator.prototype.(anonymous function) [as throw] (/Users/joshua/Projects/my-electron-app/node_modules/regenerator-runtime/runtime.js:117:21)
    at Generator.tryCatcher (/Users/joshua/Projects/my-electron-app/node_modules/electron-forge/node_modules/bluebird/js/release/util.js:16:23)
    at PromiseSpawn._promiseRejected (/Users/joshua/Projects/my-electron-app/node_modules/electron-forge/node_modules/bluebird/js/release/generators.js:107:10)
    at Promise._settlePromise (/Users/joshua/Projects/my-electron-app/node_modules/electron-forge/node_modules/bluebird/js/release/promise.js:576:26)
    at Promise._settlePromise0 (/Users/joshua/Projects/my-electron-app/node_modules/electron-forge/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/Users/joshua/Projects/my-electron-app/node_modules/electron-forge/node_modules/bluebird/js/release/promise.js:689:18)
    at Async._drainQueue (/Users/joshua/Projects/my-electron-app/node_modules/electron-forge/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/Users/joshua/Projects/my-electron-app/node_modules/electron-forge/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues (/Users/joshua/Projects/my-electron-app/node_modules/electron-forge/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:666:20)
    at tryOnImmediate (timers.js:639:5)
    at processImmediate [as _immediateCallback] (timers.js:611:5)

What command line arguments are you passing?

electron-forge make

What does your config.forge data in package.json look like?

    "config": {
        "forge": "./ember-electron/electron-forge-config.js"
    }
const path = require("path");

function getSigningCert() {
    if (process.platform !== "win32") {
        return;
    }

    if (process.env.CODESIGN_CERTIFICATE) {
        return process.env.CODESIGN_CERTIFICATE;
    } else {
        console.log("Codesigning certificate can not be found, release build will fail");
        console.log("To fix, set CODESIGN_CERTIFICATE");
    }
}

function getSigningPassword() {
    if (process.platform !== "win32") {
        return;
    }

    if (process.env.CODESIGN_PASSWORD) {
        return process.env.CODESIGN_PASSWORD;
    } else {
        console.log("Codesigning password can not be found, release build will fail");
        console.log("To fix, set CODESIGN_PASSWORD");
    }
}
module.exports = {
    "make_targets": {
        "win32": [
            "squirrel",
            "appx",
            "zip"
        ],
        "darwin": [
            "dmg",
            // "zip"
        ],
        // "linux": [
        //   "deb",
        //   "rpm"
        // ]
    },
    "electronPackagerConfig": {
        name: "MyApp",
        appCopyright: "Copyright (c) 2017 MyApp",
        versionString: {
            CompanyName: "Me",
            FileDescription: "MyApp",
            ProductName: "MyApp",
            InternalName: "MyApp"
        },
        protocols: [{
            name: "MyApp Universal",
            schemes: ["my-app"]
        }],
        protocol: ["my-app"],
        protocolName: "MyApp Universal",
        overwrite: true,
        icon: "assets/icons/my-app"
    },
    "electronInstallerDMG": {
        title: "MyApp",
        background: "assets/dmg/installer_background.png",
        icon: "assets/icons/my-app.icns",
        iconsize: 100,
        window: {
            size: {
                width: 600,
                height: 571
            }
        }
    },
    "electronWinstallerConfig": {
        name: "MyApp",
        icon: "assets/icons/my-app",
        noMsi: true,
        authors: "Me",
        exe: "MyApp.exe",
        // iconUrl: ``,
        setupIcon: path.join(__dirname, "../../../assets/icons/my-app.ico"),
        title: "MyApp",
        loadingGif: path.join(__dirname, "../../../assets/win/installer-dev.gif"),
        // certificateFile: getSigningCert(),
        // certificatePassword: getSigningPassword()
    },
    "electronInstallerRedhat": {},
    "windowsStoreConfig": {
        // containerVirtualization: false,
        // inputDirectory: 'C:\\input\\',
        // outputDirectory: 'C:\\output\\',
        // flatten: false,
        // packageVersion: '1.0.0.0',
        packageName: "MyApp",
        packageDisplayName: "MyApp",
        packageDescription: "MyApp",
        packageExecutable: "app/MyApp.exe"
        // assets: 'C:\\assets\\',
        // manifest: 'C:\\AppXManifest.xml',
        // deploy: false,
        // publisher: 'CN=developmentca',
        // windowsKit: 'C:\\windowskit',
        // devCert: 'C:\\devcert.pfx',
        // desktopConverter: 'C:\\desktop-converter-tools',
        // expanedBaseImage: 'C:\\base-image.wim',
        // makeappxParams: ['/l'],
        // signtoolParams: ['/p'],
        // makePri: true,
        // createConfigParams: ['/a'],
        // createPriParams: ['/b']
    }
};

};
jfrux commented 7 years ago

So I've updated my issue because it only seems to be affecting the dmg make target.

MarshallOfSound commented 7 years ago

@joshuairl What version of electron-forge is this?

EDIT: Of note in the stack trace it looks like a promise was rejected _promiseRejected and from a cursory inspection of the transpiled code the .call is pushing the error onto the promise context (not our code).

jfrux commented 7 years ago

Sorry! Appears to be electron-forge@3.0.0?

MarshallOfSound commented 7 years ago

@joshuairl I don't see it changing too much but can you update to latest. (3.0.1)

jfrux commented 7 years ago

So it's definitely happening because of a "file not found" error on background or icon property in electronInstallerDMG. It's just not showing file not found, or anything of the sorts. It appears to be getting snuffed by a try / catch somewhere.

But it's not a very descriptive error message so took me a bit to debug.

I can try updating to 3.0.1, but it doesn't appear to affect this issue.

jfrux commented 7 years ago

When I fixed the paths, it works now.

MarshallOfSound commented 7 years ago

Yeah, that was what I was inferring this edit 👍

EDIT: Of note in the stack trace it looks like a promise was rejected _promiseRejected and from a cursory inspection of the transpiled code the .call is pushing the error onto the promise context (not our code).

Looks like a bug in one of our babel transpilers, I will try to repro and follow up with them but async/await transpilation might be beyond me 😆

MarshallOfSound commented 7 years ago

Closing this out for now as it's an upstream babel transpilation issue that afaics has already been fixed (just needed a clean release 😆 )