Commit 4a1283c958a5ddcc50da3e75ed1c3c71b0236c56
Improve handling stream ending
Charles Lehner committed on 2/19/2016, 3:19:19 PMParent: 9bfd8551bbfc41059d347102b284dc7e828d99d4
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -79,9 +79,9 @@ | ||
79 | 79 | |
80 | 80 | // read upload request (wants list) from client |
81 | 81 | var readWant = lines.wants() |
82 | 82 | readWant(null, function (end, want) { |
83 | - if (end === true) return // early client disconnect | |
83 | + if (end === true) return cb(true) // early client disconnect | |
84 | 84 | else if (end) cb(end) |
85 | 85 | else nextWant(null, want) |
86 | 86 | }) |
87 | 87 | function nextWant(end, want) { |
@@ -294,8 +294,9 @@ | ||
294 | 294 | pull( |
295 | 295 | lines.updates, |
296 | 296 | pull.collect(function (err, updates) { |
297 | 297 | if (err) return cb(err) |
298 | + if (updates.length === 0) return cb(true) | |
298 | 299 | repo.update(pull.values(updates), pull( |
299 | 300 | lines.passthrough, |
300 | 301 | pack.decode(options, repo, done()) |
301 | 302 | ), done()) |
@@ -401,11 +402,12 @@ | ||
401 | 402 | // HACK: silence error when writing to closed stream |
402 | 403 | try { |
403 | 404 | cb(null, data) |
404 | 405 | } catch(e) { |
405 | - if (e.message == 'process.stdout cannot be closed.') | |
406 | + if (e.message == 'process.stdout cannot be closed.' | |
407 | + || e.message == 'This socket is closed.') | |
406 | 408 | process.exit(1) |
407 | - else throw e | |
409 | + throw e | |
408 | 410 | } |
409 | 411 | } |
410 | 412 | }) |
411 | 413 | } |
Built with git-ssb-web