Commit 89903ba2fa42a5bb486607c2b44b9d740697af3b
Fix handling early client disconnect on fetch
Charles Lehner committed on 2/18/2016, 9:23:44 PMParent: 6198d3e1ad4b68fee408f6eade0a3ec353c06a25
Files changed
index.js | changed |
test/run.js | changed |
index.js | ||
---|---|---|
@@ -80,12 +80,11 @@ | ||
80 | 80 | |
81 | 81 | // read upload request (wants list) from client |
82 | 82 | var readWant = lines.wants() |
83 | 83 | readWant(null, function (end, want) { |
84 | - // client may disconnect before sending wants | |
85 | - if (end === true) cb(true) | |
84 | + if (end === true) return // early client disconnect | |
86 | 85 | else if (end) cb(end) |
87 | - else readWant(null, nextWant) | |
86 | + else nextWant(null, want) | |
88 | 87 | }) |
89 | 88 | function nextWant(end, want) { |
90 | 89 | if (end) return wantsDone(end === true ? null : end) |
91 | 90 | if (want.type == 'want') { |
@@ -99,9 +98,8 @@ | ||
99 | 98 | readWant(null, nextWant) |
100 | 99 | } |
101 | 100 | |
102 | 101 | function wantsDone(err) { |
103 | - console.error('wants done', err) | |
104 | 102 | if (err) return cb(err) |
105 | 103 | // Read upload haves (haves list). |
106 | 104 | // On first obj-id that we have, ACK |
107 | 105 | // If we have none, NAK. |
Built with git-ssb-web