Skip to content

Commit

Permalink
Fix memory leak.
Browse files Browse the repository at this point in the history
  • Loading branch information
satazor committed Mar 28, 2016
1 parent 4458d6d commit 322fe4c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/iteratorCaller.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ class IteratorCallerStream extends SwiftTransformStream {

// Execute the iterator
// Note that the iterator can throw synchronously as well as return non-promise values
return Promise.resolve()
.then(() => this._iterator(data))
new Promise((resolve, reject) => {
Promise.resolve(this._iterator(data))
.then(resolve, reject);
})
.then(() => callback(null, data), (err) => callback(err))
// Equivalent to .done()
.catch((err) => {
Expand Down
6 changes: 4 additions & 2 deletions lib/iteratorCallerBulk.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ class IteratorCallerBulkStream extends TransformStream {

// Execute the iterator
// Note that the iterator can throw synchronously as well as return non-promise values
return Promise.resolve()
.then(() => this._iterator(this._buffer))
return new Promise((resolve, reject) => {
Promise.resolve(this._iterator(this._buffer))
.then(resolve, reject);
})
.then(() => { this._buffer = []; });
}
}
Expand Down

0 comments on commit 322fe4c

Please sign in to comment.