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

Callback is triggered even if not finished #127

Open
hgouveia opened this issue Feb 7, 2018 · 2 comments
Open

Callback is triggered even if not finished #127

hgouveia opened this issue Feb 7, 2018 · 2 comments

Comments

@hgouveia
Copy link

hgouveia commented Feb 7, 2018

I'm copying some binaries file to another folder, then executing a binary in the callback
but i'm getting as a result Error: spawn EBUSY

internal/child_process.js:328
    throw errnoException(err, 'spawn');
    ^

Error: spawn EBUSY
    at exports._errnoException (util.js:1020:11)
    at ChildProcess.spawn (internal/child_process.js:328:11)
    at exports.spawn (child_process.js:370:9)

The Script:

const spawn = require("child_process").spawn;
const execPath = path.resolve( __dirname, "/dest" );
const binPath = path.resolve( __dirname, "/.bin" );

rimraf(execPath, function (err) {

    if (err) {
        throw err;
    }

    mkdirp(execPath, {}, function (err) {
        if (err) {
            throw err;
        }

        ncp(binPath , execPath, { clobber: false }, function (err) {
            if (err) {
                throw err;
            }

            let args = ["--arg1"];
            let cmd = path.resolve(execPath , "sometool.exe");
            spawn(cmd, args);
        });
    });
});

if i add a setTimeout where the binary is called, it works

const spawn = require("child_process").spawn;
const execPath = path.resolve( __dirname, "/dest" );
const binPath = path.resolve( __dirname, "/.bin" );

rimraf(execPath, function (err) {

    if (err) {
        throw err;
    }

    mkdirp(execPath, {}, function (err) {
        if (err) {
            throw err;
        }

        ncp(binPath , execPath, { clobber: false }, function (err) {
            if (err) {
                throw err;
            }

            let args = ["--arg1"];
            let cmd = path.resolve(execPath , "sometool.exe");
            

            //NOW IT WORKS
            setTimeout( ()=> spawn(cmd, args), 1000); 

        });
    });
});
@julienw
Copy link

julienw commented Feb 17, 2018

I think I encountered the same issue: calling "ncp", then git add ., and the copied file isn't present.

@andrewjmead
Copy link

Yup. I'm running into the same issue as @julienw. I'm running git add . after the callback fires. This doesn't work as expected because the files aren't copied even though the callback ran without errors.

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

3 participants