Skip to content

Commit

Permalink
chore: add comment explaining throw + reject
Browse files Browse the repository at this point in the history
  • Loading branch information
Gozala committed Aug 17, 2020
1 parent a6673df commit 3c127ce
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/it-multipart/index.js
Expand Up @@ -197,6 +197,13 @@ function waitForStreamToBeConsumed (stream) {

return next
} catch (err) {
// By rejecting `completion` propagate error to the
// A. `for await (cons part of multipart(...))`
// By throwing we propagate error to the
// B. `for await (const chunk of part.body)`
// We need to do both because if we just do A. error will not appear to
// the consumer of `part.body`, furthermore A might break a loop before
// completion and error may get swallowed.
pending.reject(err)
throw err
}
Expand Down

0 comments on commit 3c127ce

Please sign in to comment.