-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed
Labels
questionIssues that look for answers.Issues that look for answers.streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.
Description
- Version: v6.7.0
- Platform: Linux david-Latitude-E6440 4.4.0-38-generic Fix for path.resolve containing relative path to another drive in windows #57-Ubuntu SMP Tue Sep 6 15:42:33 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
- Subsystem: stream
This program prints "END":
const s = new require('stream').PassThrough();
function readable()
{
console.log(this.read());
}
s.end();
setTimeout(function ()
{
s.on('readable', readable);
s.on('end', function ()
{
console.log("END");
});
}, 1000);whereas this program does not:
const s = new require('stream').PassThrough();
function readable()
{
console.log(this.read());
}
s.on('readable', readable);
s.removeListener('readable', readable);
s.end();
setTimeout(function ()
{
s.on('end', function ()
{
console.log("END");
});
}, 1000);The only difference is that a readable listener is added and then removed before the stream is ended.
My question is whether the behaviour should be the same, given that there is no readable listener in both cases when the stream is ended.
I can see in the code why: At https://github.com/nodejs/node/blob/v6.7.0/lib/_stream_readable.js#L696 readableListening is set to true but it's never reset to false if all readable listeners are removed.
Before making any changes however, I'd like to ask whether this is intended behaviour?
Metadata
Metadata
Assignees
Labels
questionIssues that look for answers.Issues that look for answers.streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.