Netflix / falcor

A JavaScript library for efficient data fetching

Home Page:http://netflix.github.io/falcor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Errors have incorrect stack traces

jmerrifield opened this issue · comments

I think the comment explaining how stacktraces will be correct is not actually true. I consistently see stack traces representing the source file of the error class, and the chain of modules that required the error class itself, rather than runtime information.

In a REPL:

> const MaxRetryExceededError = require('falcor/lib/errors/MaxRetryExceededError')
undefined
> new MaxRetryExceededError().stack
'MaxRetryExceededError\n    at Object.<anonymous> (/Users/jon/dev/project/node_modules/falcor/lib/errors/MaxRetryExceededError.js:15:35)
  at Module._compile (module.js:541:32)
  at Object.Module._extensions..js (module.js:550:10)
  at Module.load (module.js:456:32)
  at tryModuleLoad (module.js:415:12)
  at Function.Module._load (module.js:407:3)
  at Module.require (module.js:466:17)
  at require (internal/module.js:20:19)
  at repl:1:13
  at REPLServer.defaultEval (repl.js:272:27)'

If I tweak the implementation somewhat I can achieve a correct stack trace:

function MaxRetryExceededError() {
    this.message = "The allowed number of retries have been exceeded.";
    Error.call(this);
    Error.captureStackTrace(this, this.constructor);
}

require('util').inherits(MaxRetryExceededError, Error);
MaxRetryExceededError: The allowed number of retries have been exceeded.
  at repl:1:1
  at REPLServer.defaultEval (repl.js:272:27)

I'm currently performing issue triage as we get ready to perform a proper release, and closing/tagging as I go.

Thanks for reporting this, we'll take a look at it soon but for now I'll flag it as a bug.

I opened up a PR (#907) that should address this.

#941 resolves this issue. The fix was released in 2.0.4.