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
exec returning null from command #724
Comments
@webOS101 how often can you reproduce this? |
Fairly consistently. I can reproduce it at will. |
This branch is only for debugging issue #724
@webOS101 would you be willing to pull down a copy of shelljs and try it out locally? $ shelljsPath=path/to/your/project/node_modules/shelljs/
$ rm -rf "$shelljsPath"
$ git clone https://github.com/shelljs/shelljs.git "$shelljsPath"
$ cd "$shelljsPath"
$ git checkout debug-724-null-exec
$ cd -
$ # try to reproduce the bug again and paste the console output on this bug |
I saw your commit and added it to my repo. I went with:
in my |
@webOS101 Still can't quite identify the error, but the |
Perhaps unsurprisingly it clocks in at about 64K. I don't know why this passes for some builds and fails for others, though. Our largest output file is 262K and it can complete without issue. |
Yeah, it seems to be pretty sizable. You can try increasing shell.exec('your-command-here', { maxBuffer: 1024*1024 });
// default is 200 * 1024 If this does fix the issue, this is probably something we should look out for specifically, so that we can give a better error message. |
Whoops, made a mistake. ShellJS has a higher default size ( |
|
I tried using the larger buffer, as suggested, but it didn't make a difference. The drive is not full, which was my first thought. Other ideas? |
It looks like one of the temp file storing the process ext code created by @nfischer Remind me why |
If This sort of thing is actually plausible. Here's a minimal example: // This example requires unix (since it uses the `yes` command
require('child_process').exec('yes', function (code) { // overflow the maxBuffer with lots of stdio
console.log('I will never get called');
}); It sounds like our external command has tons of output, so this makes some sense. If this really is the case, then I think we can make some progress by wrapping Unfortunately, I can't find a command that will consistently break
Yes, that's exactly the reason |
@webOS101 Would you be able to try the latest version of the branch again? I added a couple more debug logs that should help confirm my suspicions. Thanks! |
I will try to do this. I had to replace that bit in my code so that I could get my build working again. I can probably check out an older version of my scripts to see what happens. |
Thanks, I appreciate the help debugging. This is a long-time bug we've never been able to repro, and I'd like to get a fix out. I'm convinced that we need to follow my try-catch suggestion regardless, but I'd like to dig deeper and see if that's really causing this issue. |
FYI: I believe I have a reproducing case of this bug as well. |
@mikeweaver what happens if you try out that branch? What do the logs show? $ rm -rf node_modules/shelljs
$ npm install 'github:shelljs/shelljs#debug-724-null-exec' |
We did a big refactor of |
Sadly no, I just hit this when running a script.
shell.ls('-Rl', '.').forEach -> same drill " Cannot read property 'forEach' of null" |
@Morphexe please file a new issue, Your problem appears to not be exec-related, but I need the info from the bug template to diagnose. |
I met the same promble in shelljs v0.8.2, and my node version is v10.8.0, How can I debug this error , please help me! |
@yuanhaisu please file a new Github issue. We need all info from the bug template. |
I'm having the same issues as @webOS101 and @yuanhaisu - node 10.9.0, shelljs 0.8.1 and 0.8.2, and macOS 10.14. Interestingly this was working two days ago, I came back to the computer and now it doesn't work:
|
@jbcpollak I'm sorry, but this should be on a separate Github issue. For example, it's not clear if you're using electron or not. |
Node version (or tell us if you're using electron or some other framework):
v6.2.1
ShellJS version (the most recent version/Github branch you see the bug on):
0.7.7
Operating system:
MacOS X 10.10
Description of the bug:
Occasionally, the
exec
command returnsnull
instead of something valid. I have an automated build script that executes. Some time during the execution of the script, it fails with the error:Example ShellJS command to reproduce the error:
These
exec
s are called in a loop and it's not the first one that fails. If I call the script outside of the automation procedure, it runs to completion without issue. I'm super stumped on this one and could use any help debugging the problem.The text was updated successfully, but these errors were encountered: