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

Property 'captureStackTrace' is not a function #18

Closed
TheLudd opened this issue Nov 14, 2014 · 7 comments
Closed

Property 'captureStackTrace' is not a function #18

TheLudd opened this issue Nov 14, 2014 · 7 comments

Comments

@TheLudd
Copy link

TheLudd commented Nov 14, 2014

Hello. I am not a direct user of verror, only indirect via restify, and I have this problem:

When running tests against my rest api and an assertion-error is thrown the entire test runner breaks down because of this error:

/home/ludwig/myproject/node_modules/restify/node_modules/verror/lib/verror.js:147
    Error.captureStackTrace(this, ctor || this.constructor);
          ^
TypeError: Property 'captureStackTrace' of object function Error() { [native code] } is not a function
  at [object Object].WError (/home/ludwig/myproject/node_modules/restify/node_modules/verror/lib/verror.js:147:8)
  at [object Object].HttpError (/home/ludwig/myproject/node_modules/restify/lib/errors/http_error.js:44:12)
  at [object Object].RestError (/home/ludwig/myproject/node_modules/restify/lib/errors/rest_error.js:41:15)
  at new module.exports.(anonymous function) (/home/ludwig/myproject/node_modules/restify/lib/errors/rest_error.js:86:19)
  at Server.<anonymous> (/home/ludwig/myproject/node_modules/restify/lib/index.js:111:18)
  at Server.emit (events.js:106:17)
  at Domain.onError (/home/ludwig/myproject/node_modules/restify/lib/server.js:775:18)
  at Domain.emit (events.js:95:17)
  at Async$_consumeLateBuffer [as _consumeLateBuffer] (/home/ludwig/myproject/node_modules/bluebird/js/main/async.js:93:27)
  at Async$_consumeFunctionBuffer [as _consumeFunctionBuffer] (/home/ludwig/myproject/node_modules/bluebird/js/main/async.js:80:10)
  at Async$consumeFunctionBuffer (/home/ludwig/myproject/node_modules/bluebird/js/main/async.js:40:14)
  at process._tickDomainCallback (node.js:463:13)

I really don't understand much of this but I notice that in some parts of the verror code there is a check: ìf (Error.captureStackTrace) before using that function. This does not exist at the specific line (147) but if I add a check at that point my problem disappears and the assertion error message is correctly printed.

Is this a check that can be added to the code to solve my problem?

@davepacheco
Copy link
Contributor

I had not seen this problem before. What version of Node is this, and on what platform?

@TheLudd
Copy link
Author

TheLudd commented Nov 14, 2014

Ubuntu 14.04, Node 0.10.33

@davepacheco
Copy link
Contributor

If you start up a Node REPL and run this, what do you get:

$ node
> Error.captureStackTrace
[Function: captureStackTrace]

@TheLudd
Copy link
Author

TheLudd commented Nov 21, 2014

Same as you

@davepacheco
Copy link
Contributor

This should be fixed by my refactoring for #10, but I'm still not sure why Error.captureStackTrace isn't present when this happens. Do you understand why that's happening?

@TheLudd
Copy link
Author

TheLudd commented Jun 23, 2016

Sorry, this was a long time ago. I can't really remember the issue and I haven't run across it since we last spoke.

@davepacheco
Copy link
Contributor

Closing as a dup of #10, which should have fixed this.

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

No branches or pull requests

2 participants