electron / forge

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

An unhandled rejection has occurred inside Forge: [object Object] #3084

Closed maks1mp closed 1 year ago

maks1mp commented 1 year ago

Pre-flight checklist

Electron Forge version

6.0.3

Electron version

18.3.15

Operating system

macOS Monteray 12.5.1

Last known working Electron Forge version

--

Expected behavior

The "make" works ok.

Actual behavior

Tried to build an electron for windows with the command:

"make:windows": "electron-forge make --platform=win32"

Getting error:

An unhandled rejection has occurred inside Forge: [object Object]

Build for macOS works fine.

Steps to reproduce

Run command:

electron-forge make --platform=win32

forge.config:

module.exports = {
  makers: [
    {
      config: {
        name: 'app-name',
      },
      name: '@electron-forge/maker-squirrel',
    },
    {
      name: '@electron-forge/maker-zip',
      platforms: ['darwin'],
    },
    {
      config: {},
      name: '@electron-forge/maker-deb',
    },
    {
      config: {},
      name: '@electron-forge/maker-rpm',
    },
  ],
  packagerConfig: {},
  rebuildConfig: {},
}

package json:

"@electron-forge/cli": "^6.0.3",
"@electron-forge/maker-deb": "^6.0.3",
"@electron-forge/maker-rpm": "^6.0.3",
"@electron-forge/maker-squirrel": "^6.0.3",
"@electron-forge/maker-zip": "^6.0.3",
"@electron-forge/template-base": "^6.0.3",

Additional information

Console output:

yarn run make:windows
yarn run v1.22.11 $ electron-forge make --platform=win32 ✔ Checking your system ✔ Loading configuration ✔ Resolving make targets › Making for the following targets: squirrel ✔ Running package command ✔ Preparing to package application ✔ Running packaging hooks ✔ Running generateAssets hook ✔ Running prePackage hook ✔ Packaging application ✔ Packaging for x64 on win32 [7s] ✔ Running postPackage hook ✔ Running preMake hook ❯ Making distributables ✖ Making a squirrel distributable for win32/x64 › An error occured while making for target: squirrel ◼ Running postMake hook

An unhandled rejection has occurred inside Forge: [object Object]

Electron Forge was terminated. Location: error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

erickzhao commented 1 year ago

Hey @maks1mp, thanks for the issue report. A few thoughts:

maks1mp commented 1 year ago

Hi, @erickzhao this is my output with DEBUG:

$ DEBUG=electron-forge:* electron-forge make --platform=win32
⠋ Checking your system
✔ Checking your system
[STARTED] Loading configuration
  electron-forge:project-resolver searching for project in: {pathToDir}/desktop-app +0ms
  electron-forge:project-resolver package.json with forge dependency found in {pathToDir}/desktop-app/package.json +2ms
[SUCCESS] Loading configuration
[STARTED] Resolving make targets
  electron-forge:require-search searching [
  '@electron-forge/maker-squirrel',
  '{pathToDir}/desktop-app/@electron-forge/maker-squirrel',
  '{pathToDir}/desktop-app/node_modules/@electron-forge/maker-squirrel'
] relative to {pathToDir}/desktop-app +0ms
  electron-forge:require-search testing @electron-forge/maker-squirrel +2ms
  electron-forge:require-search searching [
  '@electron-forge/maker-zip',
  '{pathToDir}/desktop-app/@electron-forge/maker-zip',
  '{pathToDir}/desktop-app/node_modules/@electron-forge/maker-zip'
] relative to {pathToDir}/desktop-app +40ms
  electron-forge:require-search testing @electron-forge/maker-zip +0ms
  electron-forge:require-search searching [
  '@electron-forge/maker-deb',
  '{pathToDir}/desktop-app/@electron-forge/maker-deb',
  '{pathToDir}/desktop-app/node_modules/@electron-forge/maker-deb'
] relative to {pathToDir}/desktop-app +2ms
  electron-forge:require-search testing @electron-forge/maker-deb +0ms
  electron-forge:require-search searching [
  '@electron-forge/maker-rpm',
  '{pathToDir}/desktop-app/@electron-forge/maker-rpm',
  '{pathToDir}/desktop-app/node_modules/@electron-forge/maker-rpm'
] relative to {pathToDir}/desktop-app +3ms
  electron-forge:require-search testing @electron-forge/maker-rpm +0ms
[DATA] Making for the following targets: squirrel
[SUCCESS] Resolving make targets
[STARTED] Running package command
[STARTED] Preparing to package application
  electron-forge:project-resolver searching for project in: {pathToDir}/desktop-app +59ms
  electron-forge:project-resolver package.json with forge dependency found in {pathToDir}/desktop-app/package.json +4ms
[SUCCESS] Preparing to package application
[STARTED] Running packaging hooks
[STARTED] Running generateAssets hook
[SUCCESS] Running generateAssets hook
[STARTED] Running prePackage hook
[SUCCESS] Running prePackage hook
[SUCCESS] Running packaging hooks
[STARTED] Packaging application
[DATA] Determining targets...
  electron-forge:packager packaging with options {
  asar: false,
  overwrite: true,
  ignore: [ /^\/out\//g ],
  quiet: true,
  dir: '{pathToDir}/desktop-app',
  arch: 'x64',
  platform: 'win32',
  afterFinalizePackageTargets: [ [AsyncFunction (anonymous)] ],
  afterComplete: [ [AsyncFunction (anonymous)] ],
  afterCopy: [ [AsyncFunction (anonymous)] ],
  afterExtract: [ [AsyncFunction (anonymous)] ],
  afterPrune: [ [AsyncFunction (anonymous)] ],
  out: '{pathToDir}/desktop-app/out',
  electronVersion: '18.3.15'
} +0ms
  electron-forge:packager targets: [ { platform: 'win32', arch: 'x64' } ] +7ms
[STARTED] Packaging for x64 on win32
[STARTED] Copying files
[SUCCESS] Copying files
[STARTED] Preparing native dependencies
[TITLE] Preparing native dependencies
[SUCCESS] Preparing native dependencies
[STARTED] Finalizing package
[SUCCESS] Finalizing package
[SUCCESS] Packaging for x64 on win32
[SUCCESS] Packaging application
[STARTED] Running postPackage hook
  electron-forge:packager outputPaths: [
  '{pathToDir}/desktop-app/out/desktop-app-win32-x64'
] +8s
[SUCCESS] Running postPackage hook
[SUCCESS] Running package command
[STARTED] Running preMake hook
[SUCCESS] Running preMake hook
[STARTED] Making distributables
[STARTED] Making a squirrel distributable for win32/x64
[FAILED] An error occured while making for target: squirrel
[FAILED] An error occured while making for target: squirrel

An unhandled rejection has occurred inside Forge:
[object Object]

Electron Forge was terminated. Location:
error Command failed with exit code 1.

I have changed the log command and got the following error:

An unhandled rejection has occurred inside Forge: {"message":"An error occured while making for target: squirrel","stack":"Failed with exit code: 255\nOutput:\nSystem.AggregateException: One or more errors occurred. () ---> System.Exception\n at Squirrel.Utility.CreateZipFromDirectory (System.String zipFilePath, System.String inFolder) [0x00119] in <1ffb1a5dca5b4f2f93386cec56fd9ec2>:0 \n --- End of inner exception stack trace ---\n at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <2c1f13c6f9ea4913bc0036d9d88cbeff>:0 \n at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00043] in <2c1f13c6f9ea4913bc0036d9d88cbeff>:0 \n at System.Threading.Tasks.Task.Wait () [0x00000] in <2c1f13c6f9ea4913bc0036d9d88cbeff>:0 \n at Squirrel.ReleasePackage.CreateReleasePackage (System.String outputFile, System.String packagesRootDir, System.Func2[T,TResult] releaseNotesProcessor, System.Action1[T] contentsPostProcessHook) [0x001f7] in <1ffb1a5dca5b4f2f93386cec56fd9ec2>:0 \n at Squirrel.Update.Program.Releasify (System.String package, System.String targetDir, System.String packagesDir, System.String bootstrapperExe, System.String backgroundGif, System.String signingOpts, System.String baseUrl, System.String setupIcon, System.Boolean generateMsi, System.Boolean packageAs64Bit, System.String frameworkVersion, System.Boolean generateDeltas) [0x00214] in <1ffb1a5dca5b4f2f93386cec56fd9ec2>:0 \n at Squirrel.Update.Program.executeCommandLine (System.String[] args) [0x00116] in <1ffb1a5dca5b4f2f93386cec56fd9ec2>:0 \n at Squirrel.Update.Program.main (System.String[] args) [0x00113] in <1ffb1a5dca5b4f2f93386cec56fd9ec2>:0 \n at Squirrel.Update.Program.Main (System.String[] args) [0x00006] in <1ffb1a5dca5b4f2f93386cec56fd9ec2>:0 \n---> (Inner Exception #0) System.Exception\n at Squirrel.Utility.CreateZipFromDirectory (System.String zipFilePath, System.String inFolder) [0x00119] in <1ffb1a5dca5b4f2f93386cec56fd9ec2>:0 <---\n\n\nError: Failed with exit code: 255\nOutput:\nSystem.AggregateException: One or more errors occurred. () ---> System.Exception\n at Squirrel.Utility.CreateZipFromDirectory (System.String zipFilePath, System.String inFolder) [0x00119] in <1ffb1a5dca5b4f2f93386cec56fd9ec2>:0 \n --- End of inner exception stack trace ---\n at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <2c1f13c6f9ea4913bc0036d9d88cbeff>:0 \n at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00043] in <2c1f13c6f9ea4913bc0036d9d88cbeff>:0 \n at System.Threading.Tasks.Task.Wait () [0x00000] in <2c1f13c6f9ea4913bc0036d9d88cbeff>:0 \n at Squirrel.ReleasePackage.CreateReleasePackage (System.String outputFile, System.String packagesRootDir, System.Func2[T,TResult] releaseNotesProcessor, System.Action1[T] contentsPostProcessHook) [0x001f7] in <1ffb1a5dca5b4f2f93386cec56fd9ec2>:0 \n at Squirrel.Update.Program.Releasify (System.String package, System.String targetDir, System.String packagesDir, System.String bootstrapperExe, System.String backgroundGif, System.String signingOpts, System.String baseUrl, System.String setupIcon, System.Boolean generateMsi, System.Boolean packageAs64Bit, System.String frameworkVersion, System.Boolean generateDeltas) [0x00214] in <1ffb1a5dca5b4f2f93386cec56fd9ec2>:0 \n at Squirrel.Update.Program.executeCommandLine (System.String[] args) [0x00116] in <1ffb1a5dca5b4f2f93386cec56fd9ec2>:0 \n at Squirrel.Update.Program.main (System.String[] args) [0x00113] in <1ffb1a5dca5b4f2f93386cec56fd9ec2>:0 \n at Squirrel.Update.Program.Main (System.String[] args) [0x00006] in <1ffb1a5dca5b4f2f93386cec56fd9ec2>:0 \n---> (Inner Exception #0) System.Exception\n at Squirrel.Utility.CreateZipFromDirectory (System.String zipFilePath, System.String inFolder) [0x00119] in <1ffb1a5dca5b4f2f93386cec56fd9ec2>:0 <---\n\n\n at ChildProcess.<anonymous> ({pathToDir}/packages/desktop-app/node_modules/electron-winstaller/lib/spawn-promise.js:49:24)\n at ChildProcess.emit (node:events:527:28)\n at ChildProcess.emit (node:domain:475:12)\n at maybeClose (node:internal/child_process:1092:16)\n at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)"}

anatoly-day-io commented 1 year ago

Experiencing the same error with snap/deb/rpm/squirell distributables on Manjaro 22, Electron 18, electron-forge 6. The binaries are ok. The error is while "Making distributables" (installers).

anatoly-day-io commented 1 year ago

Debugged myself by editing node_modules/@electron-forge/cli/dist/util/terminate.js. Was able to build after adding author, description and license fields.

maks1mp commented 1 year ago

@anatoly-day-io does not work for me.

yishayhaz commented 1 year ago

I am facing the same issue now, waiting for updates 😿

VerteDinde commented 1 year ago

@maks1mp @anatoly-day-io @yishayhaz For the folks experiencing this issue, would it be possible for you to include a copy of your repo, or a base repro case? I just tried to reproduce this on Windows with the basic template and didn't hit this error - any additional information or a repro case provided would be very helpful.

erickzhao commented 1 year ago

Hi all,

The exact error message that folks are running into here (An unhandled rejection has occurred inside Forge: [object Object]) is a generic error that happens whenever any unhandled error in a Maker bubbles all the way up to the core API.

This means the problem reported in this GitHub issue has many root problems and many solutions, and therefore has very limited usefulness in its current form.

I have opened #3086 to give you more helpful error feedback when you hit an error at the Make step, which will hopefully land for Forge v6.0.4.

In the meantime, I would suggest following @anatoly-day-io's workaround and hacking node_modules/@electron-forge/cli/dist/util/terminate.js to log the full Object rather than the stringified [object Object]:

process.on('unhandledRejection', (reason, promise)=>{
+ console.log(JSON.stringify(reason))
    redConsoleError('\nAn unhandled rejection has occurred inside Forge:');
erickzhao commented 1 year ago

@maks1mp for your exact error, I would install https://www.mono-project.com/docs/getting-started/install/mac/ if you haven't already.

erickzhao commented 1 year ago

If folks need additional help debugging their specific issues after getting past the [object Object], I would recommend: