mafintosh / mafintosh/parallel-transform
Emits `finish` dispite still consuming
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 80
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Description
The following code is a copy of an example in README **plus** `finish` event. I assumed the parallel transform emits `finish` after all data consumption but is didn't.
```javascript
var stream = transform(10, function (data, callback) {
setTimeout(function () {
callback(null, data);
}, Math.random() * 1000);
});
for (var i = 0; i < 10; i++) {
stream.write('' + i);
}
stream.end();
stream.on('finish', function () {
console.log('stream has finished');
});
stream.on('end', function () {
console.log('stream has ended');
});
```
output
```
0
stream has finished
1
2
3
4
5
6
7
8
9
stream has ended
```
This is not pleasant especially when we use libs such as `pump` that calls a callback function depending on `finish` event.
It seems that it emits `finish` **after all writable data is buffered** instead of consumed.
This problem occurs also in `parallel-stream` module.
Also, when we do `readable.pipe(parallelTransform).pipe(writable)`, the writable emits `finish` earlier than expected.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the README example and run the reproduction shown in the issue to observe the finish and end event ordering. Then trace the transform stream's writable and readable event handling, including the reported parallel-stream and pump interactions. Done means the event sequence reflects consumption completion and the piped writable no longer finishes prematurely.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100