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

Download manifest seems to not be cached, which leads to failures when builds are run in parallel #1089

Open
1 of 3 tasks
CosmoMyzrailGorynych opened this issue May 14, 2024 · 2 comments
Assignees

Comments

@CosmoMyzrailGorynych
Copy link
Contributor

Issue Type

  • Bug Report
  • Feature Request
  • Other

Current/Missing Behaviour

Running several nwbuilder calls in parallel sometimes fails with this error:

The version manifest does not exist/was not downloaded. Please try again in some time.
TypeError: Cannot read properties of undefined (reading 'components')
    at bld (file:///builds/CoMiGo/ct-js/node_modules/nw-builder/src/bld.js:170:35)
    at async nwbuild (file:///builds/CoMiGo/ct-js/node_modules/nw-builder/src/index.js:116:7)
    at async Promise.all (index 1)
    at async bakePackages (file:///builds/CoMiGo/ct-js/gulpfile.mjs:504:5)

I do run the first build separately so the manifest can be downloaded without overwrites:

/**
 * Array of tuples with platform — arch — itch.io channel name in each element.
 * Note how win32 platform is written as just 'win' (that's how nw.js binaries are released).
 */
let platforms = [
    ['linux', 'ia32', 'linux32'],
    ['linux', 'x64', 'linux64'],
    ['osx', 'x64', 'osx64'],
    ['osx', 'arm64', 'osxarm'],
    ['win', 'ia32', 'win32'],
    ['win', 'x64', 'win64']
];
if (process.platform === 'win32') {
    platforms = platforms.filter(p => p[0] !== 'osx');
    console.warn('⚠️  Building packages for MacOS is not supported on Windows. This platform will be skipped.');
}
const nwBuilderOptions = {
    version: nwVersion,
    flavor: 'sdk',
    srcDir: './app/',
    glob: false
};
/* ... */
export const bakePackages = async () => {
    /* ... */
    const builder = pf => {
        const [platform, arch, itchChannel] = pf;
        log.info(`'bakePackages': Building for ${platform}-${arch}…`);
        return nwBuilder({
            ...nwBuilderOptions,
            mode: 'build',
            platform,
            arch,
            outDir: `./build/ctjs - v${pack.version}/${itchChannel}`,
            zip: false
        });
    };
    // Run first build separately so it fetches manifest.json with all nw.js versions
    // without occasional rewrites and damage. ⬅️ wishful thinking here 😢 
    await builder(platforms[0]);
    await Promise.all(platforms.slice(1).map(builder));
    /* ... */
}

From what happens, I guess the downloads manifest is re-downloaded on each nwbuilder run.

Expected/Proposed Behaviour

It should be possible to run builds in parallel.

Additional Info

It would also be cool if there was a separate call to fetch download manifest only, like mode: 'fetch'

@ayushmanchhabra
Copy link
Collaborator

Will look into it. Usually afk during the week but will try to work on the weekend.

@ayushmanchhabra ayushmanchhabra self-assigned this May 15, 2024
CosmoMyzrailGorynych added a commit to ct-js/ct-js that referenced this issue May 21, 2024
@ayushmanchhabra
Copy link
Collaborator

ayushmanchhabra commented May 25, 2024

On every build, the versions manifest (nwjs.io/versions.json) is redownloaded (in the event it is updated in between. The error is most probably because two build processes are trying to write to the same location.

Possible solution is to cache versions manifest and remove it after some time has passed (set a timeout for 5 minutes for example). One edge case that comes to mind: if cache is invalidated but no network connection present, then it should use the existing cache and not delete it.

If you're running parallel builds, then both functions should atleast have the same timeout.

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

No branches or pull requests

2 participants