callsite
callsite copied to clipboard
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?
(Updated with better example)
And of course as soon as I post this I find out my primary issue (I had omitted displayErrors:true in the vm / loader logic). Although I would love to know what flags VS uses to run Node so I can get as much detail.