occ / TraceKit

Attempts to create stack traces for unhandled JavaScript exceptions in all major browsers.
1.06k stars 70 forks source link

TraceKit doesn't handle well callstacks with "new " #66

Closed vitalybe closed 9 years ago

vitalybe commented 10 years ago

Consider the following callstack:

21:57:23,727 ERROR - Error: BEEP2
    new <anonymous>@https://webclient.mini.net/tmp/scripts/index.js:643:11
    d@https://webclient.mini.net/tmp/scripts/libraries.js:34:265
    Object.instantiate@https://webclient.mini.net/tmp/scripts/libraries.js:34:394
    $get@https://webclient.mini.net/tmp/scripts/libraries.js:66:112
    {anonymous}()@https://webclient.mini.net/tmp/scripts/libraries.js:53:14
    q@https://webclient.mini.net/tmp/scripts/libraries.js:7:386
    J@https://webclient.mini.net/tmp/scripts/libraries.js:52:382
    f@https://webclient.mini.net/tmp/scripts/libraries.js:46:399
    {anonymous}()@https://webclient.mini.net/tmp/scripts/libraries.js:46:67
    {anonymous}()@https://webclient.mini.net/tmp/scripts/libraries.js:18:67

This line: new <anonymous>@https://webclient.mini.net/tmp/scripts/index.js:643:11 isn't being handled properly by the regex here:

function computeStackTraceFromStackProp(ex) {
    if (!ex.stack) {
        return null;
    }

    var chrome = /^\s*at (?:((?:\[object object\])?\S+(?: \[as \S+\])?) )?\(?((?:file|https?|chrome-extension):.*?):(\d+)(?::(\d+))?\)?\s*$/i,
    ...

Here is a fix suggestion: ^\s*at (?:((?:\[object object\])?(?:new )?\S+(?: \[as \S+\])?) )?\(?((?:file|https?|chrome-extension):.*?):(\d+)(?::(\d+))?\)?\s*$

Basically I just added optional (?:new )? after the optional "[object object]" capture.

Not exactly sure, however, how it affects other browsers or other cases.

niemyjski commented 9 years ago

@vitalybe , I'm helping maintain TraceKit upstream.. If you want to recreate all the issues / pull requests in the master (https://github.com/csnover/TraceKit) I'll participate in the discussion and merge them in! I'm not sure about that change. Have you made it locally? Have you ran into any issues with it?

niemyjski commented 9 years ago

I believe this issue has been fixed in the root repository: https://github.com/csnover/TraceKit Can you please let me know if it isn't by opening a new issue in the root repo.