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

cordovaOptions glob array resources copy not being waited for #14

Open
Sinjhin opened this issue Mar 27, 2017 · 2 comments
Open

cordovaOptions glob array resources copy not being waited for #14

Sinjhin opened this issue Mar 27, 2017 · 2 comments
Labels

Comments

@Sinjhin
Copy link

Sinjhin commented Mar 27, 2017

This seems to be a race-condition.
This has been an issue before we upgraded to steal-cordova 1.0.0 but it seems that the upgrade made the problem go from having to run the build command a few times, to it not working at all unless we take out the command to delete the build directory from the start of our build script.

The error complains that a file specified in the glob array used with steal-cordova does not exist. The file that errors is different each time until the build finally succeeds.

Installing "cordova-plugin-email-composer" for ios


Done-> cordova plugin add cordova-plugin-email-composer
Running:/Users/sinjhin/Workspace/myproject/node_modules/cordova/bin/cordova plugin add cordova-plugin-device
Fetching plugin "cordova-plugin-device" via npm


Installing "cordova-plugin-device" for ios


Done-> cordova plugin add cordova-plugin-device
Success-> with Series tasks
Success-> with Series tasks
Potentially unhandled rejection [3] Error: ENOENT: no such file or directory, chmod '/Users/sinjhin/Workspace/myproject/build/cordova/www/resources/icons/android/icon-144-xxhdpi.png'
    at Error (native)

The temp fix has been to remove npm run clean && from our build script "build": "npm run clean && node build" in our package.json to keep the build dir contents intact. We still have to run the build 2-7 times before it stops giving the file errors listed above. Once the build succeeds it always seems to work the 1st time.

When switching between an iOS and Android build I manually delete the build folder and have to go through the 2-7 runs again for it to complete.

@Sinjhin Sinjhin added the bug label Mar 27, 2017
@Alfredo-Delgado
Copy link
Contributor

Alfredo-Delgado commented Jun 7, 2017

This went from a nuisance to a blocker on a recent project. I tracked the problem down to the copy method from fs-extra. I confirmed that the problem is present in its latest version (v3.0.1), too. steal-cordova is utilizing it to copy production file globs here.

@jdalton reported a similar problem with the move method here: jprichardson/node-fs-extra#357

The underlying problem appears to be with ncp. fs-extra is dealing with it via a rewrite which is a WIP: jprichardson/node-fs-extra#374

I'm dealing with it, locally, by patching lines 68-70 with:

    var copies = files.map(function(file) {                                                                                                                         
        return copy(file, destPath(file))                                                                                                                           
            .catch(function(error) {                                                                                                                                
                console.error('First attempt at copying', file,                                                                                                     
                    'failed because of', error, 'Trying again...');                                                                                                 
                                                                                                                                                                    
                return copy(file, destPath(file));                                                                                                                  
            });                                                                                                                                                     
    });                                                                                                                                                             

It's not a sexy solution, but it's made it so I can build without random crashes.

@Alfredo-Delgado
Copy link
Contributor

Looks like the upstream problem with fs-extra was resolved with jprichardson/node-fs-extra#502?

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

2 participants