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

exec and execSync git clone private_repo + timeout hangs the REPL #9146

Closed
amasad opened this issue Oct 18, 2016 · 12 comments
Closed

exec and execSync git clone private_repo + timeout hangs the REPL #9146

amasad opened this issue Oct 18, 2016 · 12 comments
Labels
child_process Issues and PRs related to the child_process subsystem. doc Issues and PRs related to the documentations. repl Issues and PRs related to the REPL subsystem.

Comments

@amasad
Copy link

amasad commented Oct 18, 2016

Expected behavior: REPL resumes working
Actual behavior: Process hangs

Description:
When git cloning a repo that requires entering a username and password in child_process.exec or child_process.execSync and hitting a timeout then the program and shell will hang. I've tried this on multiple machines. Here is repro code that uses a private repo of mine (notice how it asks for the username and then the program and shell hangs):

> child_process.execSync('git clone https://github.com/amasad/repl-it-web', { timeout: 1000, stdio: ['ignore']})
Username for 'https://github.com': Error: spawnSync /bin/sh ETIMEDOUT
    at exports._errnoException (util.js:893:11)
    at spawnSync (child_process.js:448:20)
    at Object.execSync (child_process.js:504:13)
    at repl:1:15
    at REPLServer.defaultEval (repl.js:270:27)
    at bound (domain.js:287:14)
    at REPLServer.runBound [as eval] (domain.js:300:12)
    at REPLServer.<anonymous> (repl.js:439:10)
    at emitOne (events.js:95:20)
    at REPLServer.emit (events.js:182:7)

Note that if I pkill node from another shell then the shell starts working again.

@amasad amasad changed the title exec and execSync git clone private_repo + timeout hangs the process exec and execSync git clone private_repo + timeout hangs the REPL Oct 18, 2016
@mscdex mscdex added child_process Issues and PRs related to the child_process subsystem. repl Issues and PRs related to the REPL subsystem. labels Oct 18, 2016
@bnoordhuis
Copy link
Member

Is this a bug report or a help question? If it's the former, can you be explicit about what the actual and expected behavior is? If it's the latter, can you move it to https://github.com/nodejs/help/issues? Thanks.

@amasad
Copy link
Author

amasad commented Oct 18, 2016

@bnoordhuis bug report. I thought it's clear that the process hangs and that shouldn't be expected. I edited to make it clear.

@bnoordhuis
Copy link
Member

Okay, thanks. What happens is that the timeout signal terminates /bin/sh but not git. Try adding { detached: true }, that makes the signal get propagated across the process group. Programs may elect to ignore SIGTERM, use { killSignal: 'SIGKILL' } if that is an issue.

It's not a node.js bug, just an artifact of the UNIX process model. I'll add documentation labels because it looks like detached isn't documented for child_process.execSync().

@bnoordhuis bnoordhuis added doc Issues and PRs related to the documentations. docs-requested labels Oct 19, 2016
@amasad
Copy link
Author

amasad commented Oct 19, 2016

Ah, great -- detached works.
It looks like exec doesn't pass on the detached option though, does it make sense to add it?

@bnoordhuis
Copy link
Member

I suppose that wouldn't hurt. Consistency is good.

@bnoordhuis bnoordhuis added the good first issue Issues that are suitable for first-time contributors. label Oct 20, 2016
@jalafel
Copy link
Contributor

jalafel commented Oct 28, 2016

Hi! I'm still fairly new to contributing, I have technically done a first contribution, but still know nothing. Would anyone mind if I took this on just to go over the documentations and understand the child_process a bit more? Thanks!

@sam-github
Copy link
Contributor

detached has a different meaning on Windows and Unix, I believe, been a while since I looked. I think it actually means something more like "detached" on Windows... i.e., it allows the child to outlive the parent process (something which is always allowed on Unix). This may be why detached isn't passed in .exec(), since node waits for the child's output with exec, it doesn't really make sense to request the child have a life time longer than the parent.

Which isn't to say that it wouldn't be more consistent to have detached be possible to specify with exec, but the docs will need to be clear about what it does (on both process models, Windows and Unix).

@sam-github
Copy link
Contributor

@jessicaquynh go for it, perhaps you even want to PR a change to allowe .detached with exec? Do you have the ability to test on Windows, to confirm if/how its different? Process model differences can be hard to determine experimentally.

/cc @orangemocha Who might know what detached really does on Windows.

@jalafel
Copy link
Contributor

jalafel commented Oct 28, 2016

@sam-github Thanks. I will do that, and yup! I have access to Windows! I will get on it. :)

@jalafel
Copy link
Contributor

jalafel commented Oct 31, 2016

@sam-github I've opened up a PR for the suggested changes. Although I ran a experimental tests between Windows and Unix, I wasn't able to spot a large difference between what's been documented. I am hoping @orangemocha may be able to clarify.

@cjihrig
Copy link
Contributor

cjihrig commented Oct 31, 2016

@orangemocha isn't around as much anymore. We could try @joaocgreis or @nodejs/platform-windows instead.

@sam-github sam-github added doc Issues and PRs related to the documentations. and removed doc Issues and PRs related to the documentations. docs-requested labels Dec 1, 2016
@Trott
Copy link
Member

Trott commented Jul 15, 2017

This issue has been inactive for sufficiently long that it seems like perhaps it should be closed. Feel free to re-open (or leave a comment requesting that it be re-opened) if you disagree. I'm just tidying up and not acting on a super-strong opinion or anything like that.

@Trott Trott closed this as completed Jul 15, 2017
@Trott Trott removed the good first issue Issues that are suitable for first-time contributors. label Jul 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
child_process Issues and PRs related to the child_process subsystem. doc Issues and PRs related to the documentations. repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

No branches or pull requests

7 participants