Code Monkey home page Code Monkey logo

Comments (8)

JoeEven avatar JoeEven commented on May 20, 2024

Ahh...
I now know that I need to run this in http method, so the stack trace seems a little changed, but still not accurate.
I run the second case in http method, and got:
In IE:
{anonymous}(null)
printStackTrace()
{anonymous}("Object expected","http://localhost/javascriptStackTrace/testcase1.html",17)
bar(1)
bar(1)
bar(1)
bar(1)
bar(1)
bar(1)
bar(1)

In FF:

(?)()@http://localhost/javascriptStackTrace/stacktrace.js:74
run(null)@http://localhost/javascriptStackTrace/stacktrace.js:72
printStackTrace()@http://localhost/javascriptStackTrace/stacktrace.js:58
onerror("abc is not defined","http://localhost/javascriptStackTrace/testcase1.html",17)@http://localhost/javascriptStackTrace/testcase1.html:8

Both of the results are not expected, is there any missing in using your library?

Thanks!

from stacktrace.js.

eriwen avatar eriwen commented on May 20, 2024

Joe: I'm looking at this.

Note that there is a bug in the IE implementation when we lose the stack if you use recursion. This is because a construct that I need is overwritten and I cannot get it back.

Regardless, this is not your fault. Your Firefox results for the test are definitely wrong using window.onerror. Stay tuned!

from stacktrace.js.

lpena avatar lpena commented on May 20, 2024

Hi, I implemented this script, used in IE9 and I found some error (maybe I did something wrong). This is the ex:

<script> var errorHandler = function(msg, file, line) { alert('error'); var trace = printStackTrace(); console.log(trace.join('\n\n')); }; window.onerror = errorHandler; function clicked() { var inputData = document.getElementById('daisa').value; alert(inputData2); } </script>

So, when the clicked function is called (by an anchor or w/e), the error occurs, the window.error is triggered and the handler is called.
So, printStrackTrace is called and the magic of the script happens, but there is an issue, some how in this part:
while (curr && stack.length < maxStackSize) {
fn = fnRE.test(curr.toString()) ? RegExp.$1 || ANON : ANON;
args = Array.prototype.slice.call(curr['arguments']);
stack[j++] = fn + '(' + this.stringifyArguments(args) + ')';
curr = curr.caller;
}
the curr['arguments'] is null so the Array.prototype.slice.call() fails and everything else stop working.
I managed to fix this by updating this the condition: while (curr && curr['arguments'] && stack.length < maxStackSize)
but I am not an expert on JS, so I wouldn't know if this condition it's good enough or not.
I found that the issue only happens in IE9. In IE 6/7/8 everything works fine, but in IE9 the force error of the script is not getting into the stack (unlike other browsers). Any thoughts? Any advice so I can hack the code a little bit to make it work in all browsers again (sadly I need IE9)
Thanks

from stacktrace.js.

eriwen avatar eriwen commented on May 20, 2024

@lpena Yep, that would be good way to fix the error you are seeing.

I would recommend that you do not use printStackTrace() within window.onerror until we have implemented a better way to handle it. Follow this issue and #26 for updates.

from stacktrace.js.

SunboX avatar SunboX commented on May 20, 2024

subscribe

from stacktrace.js.

JamesMGreene avatar JamesMGreene commented on May 20, 2024

Subscribe

from stacktrace.js.

lowbatteries avatar lowbatteries commented on May 20, 2024

subscribe

from stacktrace.js.

eriwen avatar eriwen commented on May 20, 2024

Closing in favor of #96.

from stacktrace.js.

Related Issues (20)

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.