Skip to content

Conversation

@estliberitas
Copy link

For current v4.x LTS call to Error#stack property
getter returns undefined if called without binding
to Error instance. The reason is that internally
getter needs error instance to be present as this.

For current v4.x LTS call to `Error#stack` property
getter returns `undefined` if called without binding
to `Error` instance. The reason is that internally 
getter needs error instance to be present as `this`.
@estliberitas
Copy link
Author

How to reproduce:

$ node --version
v4.4.3

$ node
> const error = new Error('foo');
undefined
> const stackDescriptor = Object.getOwnPropertyDescriptor(error, 'stack');
undefined
> stackDescriptor.get()
undefined
> stackDescriptor.get.call(error);
'Error: foo\n    at repl:1:15\n    at REPLServer.defaultEval (repl.js:262:27)\n    at bound (domain.js:287:14)\n    at REPLServer.runBound [as eval] (domain.js:300:12)\n    at REPLServer.<anonymous> (repl.js:431:12)\n    at emitOne (events.js:82:20)\n    at REPLServer.emit (events.js:169:7)\n    at REPLServer.Interface._onLine (readline.js:211:10)\n    at REPLServer.Interface._line (readline.js:550:8)\n    at REPLServer.Interface._ttyWrite (readline.js:827:14)'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant