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

Custom async sign function causes build to fail #2613

Closed
MaKleSoft opened this issue Feb 20, 2018 · 4 comments
Closed

Custom async sign function causes build to fail #2613

MaKleSoft opened this issue Feb 20, 2018 · 4 comments
Labels

Comments

@MaKleSoft
Copy link

  • Version: 20.0.7
  • Target: mac

I'm using a custom singing function for windows. Since updating to the latest version of electron-builder, the build fails with the following exception:

YAMLException: unacceptable kind of an object to dump [object AsyncFunction]
    at writeNode (/Users/martin/workspace/padlock/node_modules/electron-builder-lib/node_modules/js-yaml/lib/js-yaml/dumper.js:748:13)
    at writeBlockMapping (/Users/martin/workspace/padlock/node_modules/electron-builder-lib/node_modules/js-yaml/lib/js-yaml/dumper.js:627:10)
    at writeNode (/Users/martin/workspace/padlock/node_modules/electron-builder-lib/node_modules/js-yaml/lib/js-yaml/dumper.js:720:9)
    at writeBlockMapping (/Users/martin/workspace/padlock/node_modules/electron-builder-lib/node_modules/js-yaml/lib/js-yaml/dumper.js:627:10)
    at writeNode (/Users/martin/workspace/padlock/node_modules/electron-builder-lib/node_modules/js-yaml/lib/js-yaml/dumper.js:720:9)
    at dump (/Users/martin/workspace/padlock/node_modules/electron-builder-lib/node_modules/js-yaml/lib/js-yaml/dumper.js:809:7)
    at /Users/martin/workspace/padlock/node_modules/electron-builder-lib/src/packager.ts:311:45
From previous event:
    at Packager._build (/Users/martin/workspace/padlock/node_modules/electron-builder-lib/out/packager.js:385:11)
    at /Users/martin/workspace/padlock/node_modules/electron-builder-lib/src/packager.ts:278:23
    at Generator.next (<anonymous>)
    at runCallback (timers.js:756:18)
    at tryOnImmediate (timers.js:717:5)
    at processImmediate [as _immediateCallback] (timers.js:697:5)
From previous event:
    at Packager.build (/Users/martin/workspace/padlock/node_modules/electron-builder-lib/out/packager.js:341:11)
    at /Users/martin/workspace/padlock/node_modules/electron-builder-lib/src/index.ts:50:40
    at Generator.next (<anonymous>)
From previous event:
    at build (/Users/martin/workspace/padlock/node_modules/electron-builder-lib/out/index.js:47:21)
    at Object.build (/Users/martin/workspace/padlock/node_modules/electron-builder/src/builder.ts:228:10)
    at rmdir.then.then.then.then.then (/Users/martin/workspace/padlock/lib/build.js:196:29)
    at <anonymous>

My config looks like this (passed as javascript object directly to builder.build:

           {
               ...
                win: {
                    publisherName: "...",
                    sign: async (opts) => {
                        ...
                    }
                },
                ...
            }

It's obvious that the builder is trying to create a yaml dump of the config object without removing any problematic objects. In this case, it's the function that could't get processed.

MaKleSoft added a commit to padloc/padloc that referenced this issue Feb 21, 2018
Replace async sign function with regular function to fix problem with electron builder (see electron-userland/electron-builder#2613)
@MaKleSoft
Copy link
Author

Update: Looks like the YAML library only has problems with async functions. Changing the sign function to a regular function returning a promise solves the problem. Not sure how easy it would be to support async functions in the config. I'm ok without it if it's too much work. In that case, feel free to close this.

@MaKleSoft MaKleSoft changed the title Custom sign function causes build to fail Custom async sign function causes build to fail Feb 21, 2018
@develar
Copy link
Member

develar commented Feb 21, 2018

I hope I will fix it today. Thanks for clear report.

@develar develar added the bug label Feb 21, 2018
@mmaietta
Copy link
Collaborator

mmaietta commented Feb 19, 2021

@develar I'm wondering if this is related to the js-yaml v3 upgrade to v4 between 22.10.4 and 22.10.5
Also potentially related: #5641

@mmaietta
Copy link
Collaborator

mmaietta commented Feb 23, 2021

Created unit tests and am able to repro on yaml3 and yaml4
https://github.com/mmaietta/electron-builder/blob/e431639d592e75a71aa3e46dc9241e7669ee8e67/test/src/configurationValidationTest.ts#L68-L94

Will continue working on this. Thanks for the great pointer on async vs Promise

[UPDATE]
@MaKleSoft can you try applying this patch to your projects? I'd like to confirm this works before opening a PR. Also, this would allow you to be unblocked until a new EB pre-release cut can be made.

app-builder-lib+22.10.5.patch

diff --git a/node_modules/app-builder-lib/out/codeSign/windowsCodeSign.js b/node_modules/app-builder-lib/out/codeSign/windowsCodeSign.js
index a379ba4..d18f90e 100644
--- a/node_modules/app-builder-lib/out/codeSign/windowsCodeSign.js
+++ b/node_modules/app-builder-lib/out/codeSign/windowsCodeSign.js
@@ -131,9 +131,9 @@ async function sign(options, packager) {
       hash,
       isNest
     };
-    await executor({ ...taskConfiguration,
+    await Promise.resolve(executor({ ...taskConfiguration,
       computeSignToolArgs: isWin => computeSignToolArgs(taskConfiguration, isWin)
-    }, packager);
+    }, packager));
     isNest = true;
 
     if (taskConfiguration.resultOutputPath != null) {

mmaietta pushed a commit to mmaietta/electron-builder that referenced this issue Feb 23, 2021
…r implementation of other config callbacks, such as `afterSign` (electron-userland#2613)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants