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

fix(builder-util): Retry flaky builder operations #4657

Conversation

abettadapur
Copy link
Contributor

There are various operations that we have found flaky and unreliable on Windows due to AntiVirus issues.
For example, the RCEdit.exe command to edit the binary information often fails

 ⨯ cannot execute  cause=exit status 1
                    errorOut=Fatal error: Unable to commit changes

But will succeed immediately after

This PR adds support to executeAppBuilder to retry operations that have failed

@darkguy2008
Copy link

Oh God, and I thought I was the only one suffering from this!

I found an easy fix for RCEdit.exe, no need to retry, a simple sleep() works. Just replace this fragment, tested & working with the latest version as of date (so it should pass Travis I guess):

const sleep = (ms) => { return new Promise(resolve => setTimeout(resolve, ms)); }
function executeAppBuilder(args, childProcessConsumer, extraOptions = {}) {
  return new Promise((resolve, reject) => {
    const command = _appBuilderBin().appBuilderPath;

    const env = Object.assign(Object.assign({}, process.env), {
      SZA_PATH: _zipBin().path7za,
      FORCE_COLOR: _chalk().default.level === 0 ? "0" : "1"
    });
    const cacheEnv = process.env.ELECTRON_BUILDER_CACHE;

    if (cacheEnv != null && cacheEnv.length > 0) {
      env.ELECTRON_BUILDER_CACHE = path.resolve(cacheEnv);
    }

    if (extraOptions.env != null) {
      Object.assign(env, extraOptions.env);
    }

    sleep(1000).then(_ => {
      const childProcess = doSpawn(command, args, Object.assign({
        env,
        stdio: ["ignore", "pipe", process.stdout]
      }, extraOptions));

      if (childProcessConsumer != null) {
        childProcessConsumer(childProcess);
      }

      handleProcess("close", childProcess, command, resolve, error => {
        if (error instanceof ExecError && error.exitCode === 2) {
          error.alreadyLogged = true;
        }

        reject(error);
      });
    });
  });
}

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 this pull request may close these issues.

2 participants