Description
- Version: v8.9.2, v8.9.3 and v9.3.0 (at least, suspect its all versions
>=8.9.2
) - Platform: All (tested OSX, Linux)
- Subsystem: N/A
Hello!
Related to #16949 and #16860 - it appears that since Node 8 there have been some issues with Object.getOwnPropertyDescriptor
.
The simplest test case is
Object.getOwnPropertyDescriptor(process.stdin._handle.__proto__, "bytesRead"))
Expected output: undefined
(pre 8.9 behavior)
Pre 8.9.2, this crashes node with a Segmentation Fault (see linked issues)
On and after 8.9.2, this returns TypeError:
> Object.getOwnPropertyDescriptor(process.stdin._handle.__proto__, "bytesRead")
TypeError: Method bytesRead called on incompatible receiver #<TTY>
at Function.getOwnPropertyDescriptor (<anonymous>)
at repl:1:8
at ContextifyScript.Script.runInThisContext (vm.js:50:33)
at REPLServer.defaultEval (repl.js:240:29)
at bound (domain.js:301:14)
at REPLServer.runBound [as eval] (domain.js:314:12)
at REPLServer.onLine (repl.js:442:10)
at emitOne (events.js:121:20)
at REPLServer.emit (events.js:211:7)
at REPLServer.Interface._onLine (readline.js:282:10)
This means that calling Object.getOwnPropertyDescripton
on a process handle fails.
At least according to https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptor - I don't see any specification for throwing a TypeError here (particularly since the Prototype is of course an Object, it even seems to violate the ES5 spec)
Can we return to returning undefined here?
After thinking about it, I believe returning a proper descriptor with a value of 0
would actually be preferable to undefined
, since bytesRead
is a getter which returns a Number. This is the case with, for example length
:
> Object.getOwnPropertyDescriptor([].__proto__, 'length')
{ value: 0,
writable: true,
enumerable: false,
configurable: false }
Thank you for your time!