Repository navigation
Cloning locks up when more than 3 at the same time. #364
Copy link
Copy link
Closed
Labels
Description
Hello,
it seems that there is a problem with ssh agent support. this example works fine:
var remote = "https://github.com/nodegit/nodegit.git"
var git = require("nodegit");
var fs = require("fs");
var path = require("path");
function rmdirSync(path) {
var files = [];
if( fs.existsSync(path) ) {
files = fs.readdirSync(path);
files.forEach(function(file,index){
var curPath = path + "/" + file;
if(fs.lstatSync(curPath).isDirectory()) { // recurse
rmdirSync(curPath);
} else { // delete file
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(path);
}
}
function clone(to) {
rmdirSync(to);
return git.Clone.clone(remote, to).then(function () {
console.log("ok!", to);
}, function (err) {
console.log("failed!", to, err);
});
}
console.log("start");
clone("/tmp/nodegit-testA").then(function() {
clone("/tmp/nodegit-testB").then(function() {
clone("/tmp/nodegit-testC").then(function() {
clone("/tmp/nodegit-testD").then(function() {
clone("/tmp/nodegit-testE").then(function() {
for (var i = 0; i < 10; i++) {
var to = "/tmp/nodegit-test" + i;
console.log("start", i);
clone(to);
}
});
});
});
});
});
console.log("end");
output:
start
end
ok! /tmp/nodegit-testA
ok! /tmp/nodegit-testB
ok! /tmp/nodegit-testC
ok! /tmp/nodegit-testD
ok! /tmp/nodegit-testE
start 0
start 1
start 2
start 3
start 4
start 5
start 6
start 7
start 8
start 9
ok! /tmp/nodegit-test2
ok! /tmp/nodegit-test3
ok! /tmp/nodegit-test1
ok! /tmp/nodegit-test0
ok! /tmp/nodegit-test4
ok! /tmp/nodegit-test5
ok! /tmp/nodegit-test6
ok! /tmp/nodegit-test7
ok! /tmp/nodegit-test8
ok! /tmp/nodegit-test9
This is fine and expected, but when I switch to using ssh agent key :
return git.Clone.clone(remote, to, {
remoteCallbacks: {
credentials: function (url, userName) {
return git.Cred.sshKeyFromAgent("");
}
}
}).then(function () {
(and a git ssh server) then nodegit can checkout one by one as before:
ok! /tmp/nodegit-testA
ok! /tmp/nodegit-testB
ok! /tmp/nodegit-testC
ok! /tmp/nodegit-testD
ok! /tmp/nodegit-testE
but will hang when called multiple times at once and never return. (No ok or failed messages for /tmp/nodegit-test0 - /tmp/nodegit-test9)
Direcotrys /tmp/nodegit-test0 to /tmp/nodegit-test3 are created:
find /tmp/nodegit-test0/
/tmp/nodegit-test0/
/tmp/nodegit-test0/.git
/tmp/nodegit-test0/.git/config
/tmp/nodegit-test0/.git/HEAD
/tmp/nodegit-test0/.git/description
/tmp/nodegit-test0/.git/info
/tmp/nodegit-test0/.git/info/exclude
/tmp/nodegit-test0/.git/hooks
/tmp/nodegit-test0/.git/hooks/README.sample
/tmp/nodegit-test0/.git/refs
/tmp/nodegit-test0/.git/refs/tags
/tmp/nodegit-test0/.git/refs/heads
/tmp/nodegit-test0/.git/objects
/tmp/nodegit-test0/.git/objects/pack
/tmp/nodegit-test0/.git/objects/info
but there is no working copy.
Can anyone give me he hint what I'm doing wrong? it is not allowed to call multiple checkout commands at the same time?
Reactions are currently unavailable
Activity
johnhaley81 commentedon Jan 22, 2015
I actually get the same thing with the first test (i.e. no
remoteCallbacks). It makes the 0-3 directories and then just dies. Waited like 20 minutes and nothing happened. I even get the result when I use a super small repo.It seems like sending out those clone commands in parallel is causing them to go into some sort of thread locked state but even when I disable threading by removing this line I still get the same behavior.
I'd say run this in series for right now. Something is definitely wrong with parallel cloning.
maxkorp commentedon Jan 30, 2015
Hrm, 3 is the magic good number on my machine. Even with very large repos, I can do 3 concurrent clones with no issue.
With 4 repos, even with very small repos, it hangs regardless. Like @johnhaley81, it doesn't seem to matter regarding the remoteCallbacks.
maxkorp commentedon Jan 30, 2015
I reworked your example into a bit of a testbed, in case anyone else gets a chance to look at it.
drieks commentedon Jan 30, 2015
Are you sure that this is required? At last for SSH this seems to be ignored...
maxkorp commentedon Jan 30, 2015
libgit2 docs don't specify, but I'd venture that if the values your passing to sshKeyFromAgent don't line up and it still works, it's hitting some default somehow.
[-]ssh agent key and multiple checkouts[/-][+]Cloning locks up when more than 3 at the same time. [/+]tbranyen commentedon Feb 28, 2015
This has been resolved via: #425