Code Monkey home page Code Monkey logo

callsite's Introduction

callsite's People

Contributors

humanchimp avatar prescod avatar ralphtheninja avatar tchollingsworth avatar tj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

callsite's Issues

TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them

When in strict mode (use strict at the top of the file) arguments.callee throws an error.

This came up for me because Babel's require-hook was transpiling this file - yes i know it probably shouldn't.

A nasty bug though because it occurs while the stack trace has been replaced, which makes it hard to find, printing an obscure message to the console.

The workarounds:

  • configure Babel to blacklist useStrict to avoid adding strict to the top of the file.
  • configure Babel to ignore callsite.js.

Regardless I propose the following change to make sure the error gets thrown if for some reason use strict is placed at the top of this file:

module.exports = function(){
  var orig = Error.prepareStackTrace;
  var callee = arguments.callee; // <- access arguments.callee here which will throw a readable error if use strict is set.
  Error.prepareStackTrace = function(_, stack){ return stack; };
  var err = new Error;
  Error.captureStackTrace(err, callee); // <- reference callee here.
  var stack = err.stack;
  Error.prepareStackTrace = orig;
  return stack;
};

Not getting all frames

I am working on a game that uses the callstack to perform security checks. I create virtual filenames to store a filename and an instance ID so I can locate the actual object instance using the information provided by callsite. I do not appear to be getting the entire stack trace, though (my virtual scripts don't appear in the trace, now). I am running Node 8.9.3 on Windows 10 for development.

`
    stack = require('callsite'),
...
    getObjectStack() {
        let isUnguarded = false, _stack = stack(), result = [];
        logger.log('getObjectStack()');
        for (let i = 0, max = _stack.length; i < max; i++) {
            let cs = _stack[i],
                fileName = cs.getFileName(),
                funcName = cs.getMethodName() || cs.getFunctionName(),
                fileParts = fileName ? fileName.split('#') : false;
            logger.log(`\t${fileName}::${funcName}`);`

Produces a stack like:

getObjectStack()
        E:\KLF\KMUD\src\GameServer.js::getObjectStack
        E:\KLF\KMUD\src\MXC.js::MXC
        E:\KLF\KMUD\src\GameServer.js::getContext
        E:\KLF\KMUD\src\FileManager.js::createFileRequest
        E:\KLF\KMUD\src\FileManager.js::loadObject
        E:\KLF\KMUD\src\EFUNProxy.js::loadObject
        E:\KLF\KMUD\lib\sys\daemon\CommandResolver.js::resolve
        /sys/daemon/CommandResolver::resolve
        E:\KLF\KMUD\lib\base\Interactive.js::processInput
        E:\KLF\KMUD\lib\base\Creator.js::preprocessInput`


Visual Studio on the other hand shows my callstack with more than twice as many frames (see attached). Why the discrepancy? How do I get ALL the frames on the stack?

callstack2vs

(Updated with better example)

make test failed

RT. The error messages show below:

ReferenceError: __line is not defined
ReferenceError: __stack is not defined
ReferenceError: __stack is not defined

Release 1.0.1

Could you please release a new version to get rid of the npm warning:

npm WARN package.json [email protected] No repository field.

This has already been fixed, but until a new version is released this warning will still appear

Please include a copy of the MIT license

Hi there, it would be great from a distribution packaging point of view if you could include a copy of the MIT license with your software, usually in a file called LICENSE.

Thanks!

Doesn't seem to work for coffeescript

better-assert tries to load the non-existent javascript file which it got from callsite instead of the coffeescript file which even has the correct line numbers thanks to source maps.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.