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

Error: Child terminated with non-zero exit code 1 #73

Closed
ucarbehlul opened this issue Sep 2, 2013 · 11 comments
Closed

Error: Child terminated with non-zero exit code 1 #73

ucarbehlul opened this issue Sep 2, 2013 · 11 comments

Comments

@ucarbehlul
Copy link

When I try to use spooky with node command I encounter this error message:

        throw er; // Unhandled 'error' event
              ^
Error: Child terminated with non-zero exit code 1
    at Spooky.<anonymous> (/Users/baysungur/dev/gtranslate_scaper/node_modules/spooky/lib/spooky.js:177:17)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at Process.ChildProcess._handle.onexit (child_process.js:789:12)

My configuration is as follows:

transport: {
            http: {
                host: 'localhost',
            }
        },    
    casper: {
        logLevel: 'debug',
        verbose: true,
    },
    child: {
        command: 'casperjs',
        port: 8081,
        script: './node_modules/spooky/lib/bootstrap.js',
        spooky_lib: './node_modules/spooky/',
        transport: 'stdio',
        bufferSize: 16 * 1024 // 16KB
    } 

when I added console.log(options.command, args.join(' ') ) to spawning code, I got this:
casperjs ./node_modules/spooky/lib/bootstrap.js --command=casperjs --port=8081 --spooky_lib=./node_modules/spooky/ --transport=stdio --bufferSize=16384

So I tried running it and I got this error:
{"jsonrpc":"2.0","method":"emit","params":["error","CasperError: Can't find module ./node_modules/spooky/lib/bootstrap/emit",[{"file":"/usr/local/Cellar/casperjs/1/libexec/bin/bootstrap.js","line":214,"function":"patchedRequire"},{"file":"./node_modules/spooky/lib/bootstrap.js","line":18,"function":""}]]}

If I replace . with pwd in the command, namely casperjspwd/node_modules/spooky/lib/bootstrap.js --command=casperjs --port=8081 --spooky_lib=pwd/node_modules/spooky/ --transport=stdio --bufferSize=16384, this time I got this error:
{"jsonrpc":"2.0","method":"emit","params":["error","Error: Cannot find module 'events'",[{"file":"phantomjs://bootstrap.js","line":289,"function":""},{"file":"phantomjs://bootstrap.js","line":254,"function":"require"},{"file":"/Users/baysungur/dev/gtranslate_scaper/node_modules/spooky/lib/stream.js","line":28,"function":""},{"file":"/Users/baysungur/dev/gtranslate_scaper/node_modules/spooky/lib/stream.js","line":142,"function":""},{"file":"/Users/baysungur/dev/gtranslate_scaper/node_modules/spooky/lib/stream.js","line":143,"function":""}]]}

I installed 1.1.0-DEV version of casperjs with brew and phantomjs (version 1.9.1) with brew as well. I installed Spooky with npm to the working directory.

It works with the stable version of casperjs but 1.1.0-DEV does not work. The reason I'm trying DEV is that xpath seems to work better in it.

Best Regards

@julianlconnor
Copy link

Heads up, I'm getting the same error, nice recon @ucarbehlul

@lawnsea
Copy link
Contributor

lawnsea commented Sep 9, 2013

Hey y'all. Sorry for the delay. We just had a baby.

@ucarbehlul, thanks for the awesome bug report. I appreciate the detective work and thorough repro info.

I'm going to try to get to the bottom of this. I just tested with v1.0.2 and v1.0.3 of Casper. The hello.js example does not work with v1.0.3. I'm not sure why, though the release notes say it is not compatible with v1.9 of Phantom, so that could be the reason.

@rumca
Copy link

rumca commented Sep 13, 2013

@lawnsea I am experiencing a similar error to this as well, I downgraded the version of PhantomJS I was using to 1.8.2 to see if that had any effect but it didn't change anything. I think it's these release notes that we want in order to try and understand the error and not the 1.0.3 ones?

When I had a read through the upgrade guide I noticed this section which mentions that "CasperJS 1.1 now internally uses PhantomJS’ native require()" so I added the line

var require = patchRequire(require);

to the top of lib/bootstrap/casper.js which dealt with the "Cannot find module 'casper'" error I was getting, but now when I run, the command just hangs. Not sure where to go from here in attempting to fix - hopefully this is of some use!

EDIT - It was hanging because I had left the transport on stdio. Adding the patch require to the top of lib/bootstrap/casper.js seemingly fixes the issue when you are running with the dev version of casper 😄

@lawnsea
Copy link
Contributor

lawnsea commented Sep 15, 2013

@rumca Thanks for the help. I'm not able to fix this with your change on my ubuntu VM, but I think you're on the right track. I'll keep y'all posted.

@lawnsea
Copy link
Contributor

lawnsea commented Sep 16, 2013

@rumca Ok, I have a fix for this locally. I'll be pushing it up later today or tomorrow.

Interestingly, the stdio hang is due to Casper's broken Function.prototype.bind polyfill.

@rumca
Copy link

rumca commented Sep 16, 2013

@lawnsea sweet, thanks for the fast fix!

@lawnsea
Copy link
Contributor

lawnsea commented Sep 23, 2013

@rumca and @ucarbehlul: I'd like to merge this and publish a new version. Any chance y'all could pull #75 in the next day or so and see if it fixes this for you?

@ucarbehlul
Copy link
Author

Seems to be working. Good job. Cheers.

@rumca
Copy link

rumca commented Sep 23, 2013

Same here, has fixed the issues I was seeing also!

@lawnsea
Copy link
Contributor

lawnsea commented Sep 23, 2013

Great! I'll cut a release tonight.

@danielkalen
Copy link

#74

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 a pull request may close this issue.

5 participants