iriscouch / traceback

Easy access to the call stack, for Node.js
Apache License 2.0
44 stars 6 forks source link

InternalError - Illegal Access when calling traceback in request callback #8

Open Ctesias opened 8 years ago

Ctesias commented 8 years ago

Node 6.2.1 traceback 0.3.1 CentOS 7

When I run the following request with callback I get an "Internal Error" with "Illegal Access"

var request = require('request'); var traceback = require('traceback');

request( { url : endpoint, headers : {Authorization: auth}, method : 'POST', json : { //ommitted} }, function(err, response, body){ if (!err && response.statusCode == 200) { if ("error" in body){ var trace = traceback()[1]; log.error(${tb.file}:${tb.method}:${tb.line}:${JSON.stringify(body)}); sendResponse(null,JSON.stringify(body),res); } else{ sendResponse(null, body.result.volumes, res); } } else{ log.error({$response.statusCode}: {$err}); sendResponse(err, body, res); } } );

response:

{ code: "InternalError", message: "illegal access" }

frauss commented 8 years ago

I'm getting the same and think I've narrowed it to the frame.js/make_easy() method.

For reason's that I don't understand the use of the object created using Object.create from the passed CallSite object causes some of the methods to throw "illegal access" errors:

function make_easy(call_site) {
  var frame = Object.create(call_site)

  frame.this      = frame.getThis()
  frame.type      = frame.getTypeName()
  frame.is_top    = frame.isToplevel()

If I use the call_site object to set the frame properties like this:

function make_easy(call_site) {
    var frame = Object.create(call_site)

    frame.this      = call_site.getThis()
    frame.type      = call_site.getTypeName()
    frame.is_top    = call_site.isToplevel()

I don't have a problem. The thing that I don't understand is what is the difference between the object created by Object.create and the parameter?

PrasadBapatla commented 8 years ago

looks like this module doesn't work with latest Node version. Works fine with Node v0.12 but doesn't work with Node v4.6. https://runkit.com/pbapatla/57ffaad85759610014ed565a

https://runkit.com/pbapatla/57ffab48a8c92e0013a5f368