Skip to content
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

.bytesWritten on several objects results in "TypeError: Cannot read property 'getBuffer' of undefined" when accessed #3298

Closed
wraithan opened this issue Oct 9, 2015 · 2 comments
Labels
net Issues and PRs related to the net subsystem.

Comments

@wraithan
Copy link

wraithan commented Oct 9, 2015

Output from my tooling running on 4.1.2: (Not sure all versions affected yet)

net.Socket.prototype.bytesWritten throws an exception: TypeError: Cannot read property 'getBuffer' of undefined
tls.TLSSocket.super_.prototype.bytesWritten throws an exception: TypeError: Cannot read property 'getBuffer' of undefined
tls.TLSSocket.prototype.bytesWritten throws an exception: TypeError: Cannot read property 'getBuffer' of undefined
tty.ReadStream.super_.prototype.bytesWritten throws an exception: TypeError: Cannot read property 'getBuffer' of undefined
tty.ReadStream.prototype.bytesWritten throws an exception: TypeError: Cannot read property 'getBuffer' of undefined
tty.WriteStream.prototype.bytesWritten throws an exception: TypeError: Cannot read property 'getBuffer' of undefined

I'm betting a single fix will fix all of them and that it is shared.

Repro:

JS:

var net = require('net')
var tls = require('tls')
var tty = require('tty')

net.Socket.prototype.bytesWritten
tls.TLSSocket.super_.prototype.bytesWritten
tls.TLSSocket.prototype.bytesWritten
tty.ReadStream.super_.prototype.bytesWritten
tty.ReadStream.prototype.bytesWritten
tty.WriteStream.prototype.bytesWritten

output:

net.js:730
  state.getBuffer().forEach(function(el) {
       ^

TypeError: Cannot read property 'getBuffer' of undefined
    at Socket.bytesWritten (net.js:730:8)
    at Object.<anonymous> (/Users/wmcdonald/devel/newrelic/api-scraper/bad-bytes-written.js:6:21)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:475:10)
    at startup (node.js:118:18)
    at node.js:952:3
@trevnorris
Copy link
Contributor

Know what the issue is. I'll post a fix later today.

@mscdex mscdex added the net Issues and PRs related to the net subsystem. label Oct 9, 2015
trevnorris added a commit to trevnorris/node that referenced this issue Oct 12, 2015
If bytesWritten is accessed before the object has been properly
constructed then return undefined.

Fixes: nodejs#3298
trevnorris added a commit that referenced this issue Oct 12, 2015
If bytesWritten is accessed before the object has been properly
constructed then return undefined.

Fixes: #3298
PR-URL: #3305
Reviewed-By: Ben Noordhuis <[email protected]>
@trevnorris
Copy link
Contributor

Actually fixed by a713024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
net Issues and PRs related to the net subsystem.
Projects
None yet
Development

No branches or pull requests

3 participants