Skip to content

Commit 86f2017

Browse files
rcpiraterenchao
andauthored
avoid chunk is undefined. (openstf#127)
* avoid “chunk is undefined” Signed-off-by: renchao <[email protected]> * fix: avoid chunk maybe undefined Signed-off-by: renchao <[email protected]> * avoid chunk is undefined Signed-off-by: renchao <[email protected]> Co-authored-by: renchao <[email protected]>
1 parent 4c4387e commit 86f2017

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/adb/parser.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,11 @@ export default class Parser {
181181
return new Bluebird<void>((resolve, reject /*, onCancel*/) => {
182182
tryRead = () => {
183183
if (howMany) {
184-
const chunk = this.stream.read(howMany);
185184
// Try to get the exact amount we need first. If unsuccessful, take
186185
// whatever is available, which will be less than the needed amount.
187-
while (chunk || this.stream.read()) {
186+
// avoid chunk is undefined.
187+
let chunk;
188+
while (chunk = this.stream.read(howMany) || this.stream.read()) {
188189
howMany -= chunk.length;
189190
targetStream.write(chunk);
190191
if (howMany === 0) {

0 commit comments

Comments
 (0)