-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Cleanup _writableState
and _readableState
access across codebase
#445
Comments
This is great! Thanks for compiling a comprehensive list. The most egregious overreaches, I think, are any of the places we reach in and directly modify state. Informational access is less bad. I'd like to encourage folks to pick these off one at a time. For changes that might require a new internal API, it'd be great to briefly discuss plans here first before cutting a PR.
|
Use public `readableObjectMode` option to construct `Transform` instead of accessing private `_readableState.objectMode`. Partially addresses #445. PR-URL: #270 Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Bert Belder <[email protected]> Reviewed-By: Chris Dickinson <[email protected]>
Of note: I'm not opposed to all non-streams access to |
We should also probably inspect userland modules to find out what people are doing with internals. |
As a heads up, I edited your issue comment to link #454 for the node.js _readableState use (sorry sorry). In the future, I can ping you instead if you'd like to keep the list maintained! |
@chrisdickinson fine by me. But think it's a good idea to reference this issue so we can see the timeline of all relevant stuff here |
Per nodejs#445 this removes a reference to this._readableState in hash._flush. It was used to get the encoding on the readable side to pass to the writable side but omiting it just causes the stream to handle the encoding issues.
Per #445 this removes a reference to this._readableState in hash._flush. It was used to get the encoding on the readable side to pass to the writable side but omitting it just causes the stream to handle the encoding issues. PR-URL: #610 Reviewed-By: Chris Dickinson <[email protected]> Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Vladimir Kurchatkin <[email protected]>
Makes streams lazy by default so crypto does not need to monky patch them in order to get good performance. This helps the state objects become part of the private api in nodejs#445.
Cross posting this from nodejs/readable-stream#109: To amend the intent of this issue a bit – the goal is not to absolutely remove all use of
Ultimately, the places where the subclasses access those state objects should be catalogued and we should look into the best way to deal with that access – whether that's promotion into a public or protected "reflection" API for subclasses. |
This issue hasn't seen any activity in almost a year. Is it still active and useful? Or not so much? |
I think it is very informative, and perhaps needs some work to be done. |
Marking as |
Refs: #445 PR-URL: #34885 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ricky Zhou <[email protected]>
Refs: #445 PR-URL: #34884 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Refs: #445 PR-URL: #34885 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ricky Zhou <[email protected]>
Refs: #445 PR-URL: #34884 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Refs: #445 PR-URL: #34885 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ricky Zhou <[email protected]>
Refs: #445 PR-URL: #34884 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Refs: #445 PR-URL: #34885 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ricky Zhou <[email protected]>
Ref: #445 PR-URL: #45063 Refs: #445 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: James M Snell <[email protected]>
Ref: #445 PR-URL: #45063 Refs: #445 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: James M Snell <[email protected]>
Ref: #445 PR-URL: #45063 Refs: #445 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: James M Snell <[email protected]>
This comment was marked as off-topic.
This comment was marked as off-topic.
Ref: #445 PR-URL: #45063 Refs: #445 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: James M Snell <[email protected]>
Ref: #445 PR-URL: #45063 Refs: #445 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: James M Snell <[email protected]>
Ref: #445 PR-URL: #45063 Refs: #445 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: James M Snell <[email protected]>
(The stalled bot doesn't appear to be working, so I've manually closed. Feel free to reopen if this is no longer stalled) |
This is a meta-issue to keep to track of all usages of
_writableState
and_readableState
outside of streams source. These properties are considered private and should not be used unless absolutely necessary. Usage of them can indicate a few things:The list of all
_writableState
and_readableState
usages:src/node.js
stdin._readableState.reading = false
. Added in commit: bb56dcc by @isaacs; (src: nix stdin _readableState.reading manipulation #454)stdin._readableState.reading = false
. Added in commit: bb56dcc by @isaacs; (src: nix stdin _readableState.reading manipulation #454)lib/_debug_agent.js
this._readableState.objectMode = true
(_debug_agent: usereadableObjectMode
option for client stream #270);lib/_http_server.js
socket._readableState.flowing = null
(TODO(isaacs): Need a way to reset a stream to fresh state IE, not flowing, and not explicitly paused.). Added in 967b5db by @isaacs;var needPause = socket._writableState.needDrain
. Added in 085dd30 by @isaacs ;req._readableState.resumeScheduled
. Not sure where this originated, but in 2efe4ab @indutny addedoldMode
check here;lib/_tls_legacy.js
this._writableState.finished
;self._readableState.length > 0
;lib/_tls_wrap.js
self._writableState.errorEmitted
(Cleanup stream state in net #465);self._writableState.errorEmitted = true
(Cleanup stream state in net #465);socket._readableState.length
;lib/child_process.js
stream._readableState.flowing
(child_process: remove redundant condition #511);lib/crypto.js
LazyTransform
thing. Is it really necessary? Maybe it should go tostream
? Maybe it should be public? Maybe transforms should be lazy by default?;this._writableState.decodeStrings = false
;this._writableState.defaultEncoding = 'binary'
;var encoding = this._readableState.encoding || 'buffer'
(crypto: remove use of this._readableState #610);lib/fs.js
allocNewPool(this._readableState.highWaterMark)
;lib/net.js
this._writableState.decodeStrings = false
(Cleanup stream state in net #465);this._readableState.flowing = false
(Cleanup stream state in net #465);this._readableState.ended
(Cleanup stream state in net #465);self._readableState.ended
;this._readableState.ended = true
(comment: ended should already be true, since this is called after the EOF errno and onread has eof'ed) (Cleanup stream state in net #465);this._readableState.endEmitted
;this._writableState.length
;this._readableState.endEmitted
;socket._writableState.length
;if (this._writableState.finished)
;self._writableState.errorEmitted
(Cleanup stream state in net #465);self._writableState.errorEmitted = true
(Cleanup stream state in net #465);self._readableState.length === 0
;state.getBuffer()
;this._readableState.reading = false
;this._readableState.ended = false
;this._readableState.endEmitted = false
;this._writableState.ended = false
;this._writableState.ending = false
;this._writableState.finished = false
;this._writableState.errorEmitted = false
(Cleanup stream state in net #465);lib/zlib.js
ws.ended
;ws.ending
;ws.needDrain
;ws.ending || ws.ended
;ws.length
;ws.length
.List of used properties:
_readableState
reading
;objectMode
;flowing
(boolean?) is used to determine which mode readable stream is in; can betrue
,false
ornull
; `null is the initial state which means that is implicitly paused;resumeScheduled
;length
;encoding
;highWaterMark
;ended
;endEmitted
;_writableState
needDrain
;ended
;ending
;finished
;errorEmitted
;decodeStrings
;defaultEncoding
;length
;getBuffer()
;/cc @chrisdickinson
The text was updated successfully, but these errors were encountered: