Node: http: OutgoingMessage is missing _writableState

Created on 24 May 2018  路  6Comments  路  Source: nodejs/node

OutgoingMessage is missing _writableState. More of a consistency issue. Not sure what the current plan is in regards to _readableState and _writableState. However, some user land modules seem to assume they exists.

stream

Most helpful comment

I do not have a paper trail, it's buried in our issue tracker. The gist is that OutgoingMessage is not a Writable, it just _quacks_ like one. The main reason for this is performance: if we made it a full writable we would lose a significant amount of throughput. OutgoingMessage does not buffer any data internally, it just forwards it to the underlining stream as fast as it can.

The overall plan is to remove the use of _readableState and _writableState across core codebase: https://github.com/nodejs/node/issues/445. We are doing this by creating accessors. Ideally those accessors could be added to OutgoingMessage, so that they can have the same interface and guarantees.

All 6 comments

Please keep in mind that both _readableState and _writeableState are internal properties and you _shouldn't_ use or rely on them in any way. There has been quite a bit of heavy refactoring on master regarding the two, and I won't be surprised if they started disappearing from places.

/cc @nodejs/streams @mcollina @mafintosh

Please keep in mind that both _readableState and _writeableState are internal properties and you shouldn't use or rely on them in any way.

I am aware of this. However, a lot of popular packages seem to make assumptions in regards to this. I remember this being discussed a long time ago, just not sure what the consensus was. I believe these were going to be made public?

I do not have a paper trail, it's buried in our issue tracker. The gist is that OutgoingMessage is not a Writable, it just _quacks_ like one. The main reason for this is performance: if we made it a full writable we would lose a significant amount of throughput. OutgoingMessage does not buffer any data internally, it just forwards it to the underlining stream as fast as it can.

The overall plan is to remove the use of _readableState and _writableState across core codebase: https://github.com/nodejs/node/issues/445. We are doing this by creating accessors. Ideally those accessors could be added to OutgoingMessage, so that they can have the same interface and guarantees.

I think this issue can be closed. Feel free to open new issues for missing accessor/etc in OutgoingMessage.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cong88 picture cong88  路  3Comments

srl295 picture srl295  路  3Comments

seishun picture seishun  路  3Comments

jmichae3 picture jmichae3  路  3Comments

vsemozhetbyt picture vsemozhetbyt  路  3Comments