Permalink
Browse files

Bug where a pipe might call the cb twice. Reported by russell_h in IRC.

  • Loading branch information...
1 parent 3a55d02 commit 9b3e58228920bdb661d07061fd45a40961547650 @isaacs isaacs committed Aug 27, 2010
Showing with 5 additions and 2 deletions.
  1. +4 −1 lib/utils/exec.js
  2. +1 −1 package.json
View
@@ -30,16 +30,19 @@ function exec (cmd, args, env, takeOver, cb) {
function logger (d) { if (d) process.binding("stdio").writeError(d+"") }
function pipe (cp1, cp2, cb) {
sys.pump(cp1.stdout, cp2.stdin)
+ var errState = null
if (log.level <= log.LEVEL.silly) {
cp1.stderr.on("data", logger)
cp2.stderr.on("data", logger)
}
cp1.on("exit", function (code) {
if (!code) return log.verbose(cp2.name || "<unknown>", "success")
cp2.kill()
- cb(new Error( "Failed "+(cp1.name || "<unknown>")+"\nexited with "+code))
+ cb(errState = new Error(
+ "Failed "+(cp1.name || "<unknown>")+"\nexited with "+code))
})
cp2.on("exit", function (code) {
+ if (errState) return
if (!code) return log.verbose(cp1.name || "<unknown>", "success", cb)
cb(new Error( "Failed "+(cp2.name || "<unknown>")+"\nexited with "+code))
})
View
@@ -1,6 +1,6 @@
{ "name" : "npm"
, "description" : "A package manager for node"
-, "version" : "0.1.27-2"
+, "version" : "0.1.27-3"
, "homepage" : "http://npmjs.org/"
, "author" : "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)"
, "contributors" :

0 comments on commit 9b3e582

Please sign in to comment.