Skip to content

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

@wraithan

Description

@wraithan

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    netIssues and PRs related to the net subsystem.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions