stream_base: expose bytesRead getter#6284
Conversation
This will provide `bytesRead` data on consumed sockets. Fix: nodejs#3021
|
cc @trevnorris |
src/stream_base.h
Outdated
| Callback<AfterWriteCb> after_write_cb_; | ||
| Callback<AllocCb> alloc_cb_; | ||
| Callback<ReadCb> read_cb_; | ||
| int bytes_read_; |
There was a problem hiding this comment.
Come to think of it, it should be uint64_t. Both int and size_t can overflow after 2 or 4 GB, which isn't out of the ordinary.
There was a problem hiding this comment.
+1 to uint_64, int would likely overflow very quickly
There was a problem hiding this comment.
Ack, with some explicit conversions.
|
@bnoordhuis should be fixed now, PTAL |
| } | ||
|
|
||
|
|
||
| const BYTES_READ = Symbol('bytesRead'); |
There was a problem hiding this comment.
I think the naming preference is something like kBytesRead
There was a problem hiding this comment.
Is it?
lib/readline.js:const KEYPRESS_DECODER = Symbol('keypress-decoder');
lib/readline.js:const ESCAPE_DECODER = Symbol('escape-decoder');
lib/repl.js:exports.REPL_MODE_SLOPPY = Symbol('repl-sloppy');
lib/repl.js:exports.REPL_MODE_STRICT = Symbol('repl-strict');
lib/repl.js:exports.REPL_MODE_MAGIC = Symbol('repl-magic');
There was a problem hiding this comment.
Ok, yep, I've seen comments both ways but the code doesn't lie ;-)
`Object.prototype.__defineGetter__` is deprecated now, use `Object.defineProperty` instead.
| void StreamBase::GetBytesRead(Local<String> key, | ||
| const PropertyCallbackInfo<Value>& args) { | ||
| StreamBase* wrap = Unwrap<Base>(args.Holder()); | ||
|
|
|
LGTM with nit. |
|
Unrelated failure on ARM: |
|
Landed in 6198472 and 8636af1, thank you! |
`Object.prototype.__defineGetter__` is deprecated now, use `Object.defineProperty` instead. PR-URL: #6284 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
`Object.prototype.__defineGetter__` is deprecated now, use `Object.defineProperty` instead. PR-URL: #6284 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
`Object.prototype.__defineGetter__` is deprecated now, use `Object.defineProperty` instead. PR-URL: #6284 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This will provide `bytesRead` data on consumed sockets. Fix: nodejs#3021 PR-URL: nodejs#6284 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
`Object.prototype.__defineGetter__` is deprecated now, use `Object.defineProperty` instead. PR-URL: nodejs#6284 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
`Object.prototype.__defineGetter__` is deprecated now, use `Object.defineProperty` instead. PR-URL: #6284 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
|
@indutny this isn't landing cleanly on v4.x... would you be able to backport? |
|
Will do a backport. |
This will provide `bytesRead` data on consumed sockets. Fix: nodejs#3021 PR-URL: nodejs#6284 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
`Object.prototype.__defineGetter__` is deprecated now, use `Object.defineProperty` instead. PR-URL: nodejs#6284 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
|
@thealphanerd here you go #6903 |
`Object.prototype.__defineGetter__` is deprecated now, use `Object.defineProperty` instead. PR-URL: #6284 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
`Object.prototype.__defineGetter__` is deprecated now, use `Object.defineProperty` instead. PR-URL: #6284 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
`Object.prototype.__defineGetter__` is deprecated now, use `Object.defineProperty` instead. PR-URL: #6284 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Checklist
Affected core subsystem(s)
stream_base
Description of change
This will provide
bytesReaddata on consumed sockets.Fix: #3021