Uh oh!
There was an error while loading. Please reload this page.
stream: support readable/writableHighWaterMark for Duplex streams - #14636
stream: support readable/writableHighWaterMark for Duplex streams#14636guymguym wants to merge 1 commit into
Conversation
gibfahn
commented
Aug 5, 2017
cc/ @nodejs/streams |
mcollina
left a comment
There was a problem hiding this comment.
Good work! There are only some nits to address!
There was a problem hiding this comment.
the copyright header is not needed for new files
There was a problem hiding this comment.
we use camelCase in general. You can use shorter names if you want.
771f20e to
078b4eeCompareguymguym
commented
Aug 5, 2017
@mcollina Thanks for the review! I fixed the comments and squashed. |
lpinca
commented
Aug 6, 2017
guymguym
commented
Aug 6, 2017
@lpinca I'm trying to understand if the failure is related to my change, and I suspect it doesn't. |
lpinca
commented
Aug 6, 2017
@guymguym you are correct, it's not related. |
There was a problem hiding this comment.
Can you grab these 3 things using destructuring?
There was a problem hiding this comment.
You could reduce duplication by doing something like this throughout the test:
[undefined,null,NaN].forEach((highWaterMark)=>{testTransform(666,DEFAULT,{
highWaterMark,readableHighWaterMark: 666});});078b4ee to
13a8f7bCompareguymguym
commented
Aug 7, 2017
@cjihrig Thanks, fixed and squashed. |
mcollina
commented
Aug 8, 2017
Landed as c3c045a. |
mcollina
commented
Aug 8, 2017
Congratulations for your first contribution to Node.js! |
mcollina
commented
Aug 8, 2017
I've added the semver-minor flag as it's a new feature. |
refack
left a comment
There was a problem hiding this comment.
A few comments a bit late. If we get some agreement I'll open a PR.
| * `writableObjectMode` {boolean} Defaults to `false`. Sets `objectMode` | ||
| for writable side of the stream. Has no effect if `objectMode` | ||
| is `true`. | ||
| * `readableHighWaterMark` {number} Sets `highWaterMark` for the readable side |
There was a problem hiding this comment.
Suggestions:
Add a link to [#buffering]
Also in the first * (options) add links to [#constructor-new-streamwritableoptions] and [#new-streamreadableoptions]
| for writable side of the stream. Has no effect if `objectMode` | ||
| is `true`. | ||
| * `readableHighWaterMark` {number} Sets `highWaterMark` for the readable side | ||
| of the stream. Has no effect if `highWaterMark` is provided. |
There was a problem hiding this comment.
I'd phrase it as The general `highWaterMark` option overrides this one. IMHO a positive-active sentence is a little bit clearer than a negative-passive one.
There was a problem hiding this comment.
I agree that positive is better. I just copied this format from readable/writableObjectMode.
| // However, some cases require setting options to different | ||
| // values for the readable and the writable sides of the duplex stream. | ||
| // These options can be provided separately as readableXXX and writableXXX. | ||
| var isDuplex = stream instanceof Stream.Duplex; |
There was a problem hiding this comment.
yes, but this was already there, this PR just moves it.
There was a problem hiding this comment.
In my opinion it is best to allow it also for Readable/Writable without checking for Duplex, because this is an inherited behavior that behaves different on the base class vs the child class, and this is more confusing than helping. Not sure if this will be agreed by any developer reading the docs though. I wonder what you guys think.
| }); | ||
| // test undefined, null, NaN | ||
| [undefined, null, NaN].forEach((v) => { |
There was a problem hiding this comment.
what happens with ['', 'foo', ()=>{}, Symbol('frog'), {}, []]?
There was a problem hiding this comment.
@refack The behavior will be unspecified in these cases, since highWaterMark is expected to be a number, but only checked to be a truthy value or 0.
This was also the case before my PR, though I would prefer it to be a specified behavior instead.
Perhaps the behavior should be to ignore non number values or else throw TypeError as a breaking change...
mcollina
commented
Aug 8, 2017
@refack go ahead and fire a PR. |
Notable changes * **Inspector** * `require()` is available in the inspector console now. [#8837](#8837) * **N-API** * New APIs for creating number values have been introduced. [#14573](#14573) * **Stream** * For `Duplex` streams, the high water mark option can now be set independently for the readable and the writable side. [#14636](#14636) * **Util** * `util.format` now supports the `%o` and `%O` specifiers for printing objects. [#14558](#14558) PR-URL: #14811
Notable changes * **HTTP2** * Experimental support for the built-in `http2` has been added via the `--expose-http2` flag. [#14239](#14239) * **Inspector** * `require()` is available in the inspector console now. [#8837](#8837) * Multiple contexts, as created by the `vm` module, are supported now. [#14465](#14465) * **N-API** * New APIs for creating number values have been introduced. [#14573](#14573) * **Stream** * For `Duplex` streams, the high water mark option can now be set independently for the readable and the writable side. [#14636](#14636) * **Util** * `util.format` now supports the `%o` and `%O` specifiers for printing objects. [#14558](#14558) PR-URL: #14811
Notable changes * **HTTP2** * Experimental support for the built-in `http2` has been added via the `--expose-http2` flag. [#14239](#14239) * **Inspector** * `require()` is available in the inspector console now. [#8837](#8837) * Multiple contexts, as created by the `vm` module, are supported now. [#14465](#14465) * **N-API** * New APIs for creating number values have been introduced. [#14573](#14573) * **Stream** * For `Duplex` streams, the high water mark option can now be set independently for the readable and the writable side. [#14636](#14636) * **Util** * `util.format` now supports the `%o` and `%O` specifiers for printing objects. [#14558](#14558) PR-URL: #14811
Notable changes * **HTTP2** * Experimental support for the built-in `http2` has been added via the `--expose-http2` flag. [#14239](nodejs/node#14239) * **Inspector** * `require()` is available in the inspector console now. [#8837](nodejs/node#8837) * Multiple contexts, as created by the `vm` module, are supported now. [#14465](nodejs/node#14465) * **N-API** * New APIs for creating number values have been introduced. [#14573](nodejs/node#14573) * **Stream** * For `Duplex` streams, the high water mark option can now be set independently for the readable and the writable side. [#14636](nodejs/node#14636) * **Util** * `util.format` now supports the `%o` and `%O` specifiers for printing objects. [#14558](nodejs/node#14558) PR-URL: nodejs/node#14811
Fixes: #14555
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
stream