-
Notifications
You must be signed in to change notification settings - Fork 29.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
streams: non-writable Duplex is writable (more annoyance than bug) #34374
Comments
Also, just to be thorough, the same issue exists with const d = new stream.Duplex({
readable: false,
read() {
this.push(Buffer.from('abc'));
this.push(null);
}
});
console.log(d.readable); // false
d.setEncoding('utf8');
d.on('data', console.log); // prints abc |
What would you like to happen? Error if write/push to a non writable/readable stream? readable/writable false should be as if end()/push(null) has been called in the constructor but without emitting the associated events? |
@ronag @jasnell |
No, they don't need to be checked. Calling it "safe" is maybe a bit misleading, but the following sentence does explain what it means in the context.
It does "work". Depends on what you mean by "works". Though that usage is deprecated.
That option actually does exist and should be used. It's just not documented, which we should fix. |
@jasnell I'll investigate what we can do to improve this. |
By "doesn't work" I meant that we are allowed to read/write on a non readable/writable
Should I open another issue regarding this? Also are there any more options other than |
Sure!
I don't think so. |
If writable/readable has been explicitly disabled then using a Duplex as writable/readable should fail. Fixes: nodejs#34374
If writable/readable has been explicitly disabled then using a Duplex as writable/readable should fail. Fixes: nodejs#34374
If writable/readable has been explicitly disabled then using a Duplex as writable/readable should fail. Fixes: nodejs#34374
@mcollina @ronag @nodejs/streams
This isn't a bug since it's been like this forever but the behavior is really counter intuitive, especially since after calling
d.end()
and then doing ad.write()
we get a properwrite after end
error. It makes implementing a customDuplex
(e.g.QuicStream
) more difficult because of the additional checks that need to be made to ensure that even tho theDuplex
isn't writable no-one is writing to it.Not sure what the fix is immediately but wanted to discuss it first.
The ideal behavior, I would think, is an error similar to
write after end
ifwrite()
is called on a non-writableDuplex
.The text was updated successfully, but these errors were encountered: