Skip to content

mapStackTrace fails to sourcemap my coffeescript files in Chrome #16

Open

Description

@dgoldstein0

Background: I'm using sourcemapped-stacktrace with jasmine 2.3.4 as suggested by https://gist.github.com/guncha/f45ceef6d483c384290a. After getting this set up, I was surprised to see that my coffeescript source lines - which are the ones I really care about - weren't being mapped at all. I wrote a simple example jasmine test to illustrate.

Here's a sample stack trace where i reproduced the problem:

"Error: Expected 5 to equal 4.
    at stack (https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1201:27)
    at buildExpectationResult (https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1176:20)
    at Spec.expectationResultFactory (https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:467:24)
    at Spec.addExpectationResult (https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:261:38)
    at Expectation.addExpectationResult (https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:428:29)
    at Expectation.toEqual (https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1143:18)
    at https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/tests/jasmine_tests/example-vflDEVHASH.js:5:24
    at Object.arguments.(anonymous function) (https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine-promises-vflDEVHASH.js:71:47)
    at attemptAsync (https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1501:32)
    at QueueRunner.run (https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1456:17)"

In particular, the line at https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/tests/jasmine_tests/example-vflDEVHASH.js:5:24 should be sourcemapped to a line in /static/coffee/tests/jasmine_tests/example.coffee. After debugging, I found that the regex chosen for Chrome (

regex = /^ +at.+\((.*):([0-9]+):([0-9]+)/;
) does not match this stack line.

example.coffee:

define [], ->
  describe "example", ->
    it "tries to test something", ->
      expect(5).toEqual(4)

This repros for essentially all coffeescript files I've tried. It's worth noting, for those unfamiliar with coffeescript, that coffeescript tends to only use anonymous functions - not sure if that has something to do with it or not.

Activity

  1. novocaine commented on Jul 9, 2016

    @novocaine
    Owner

    Hi,

    Sorry to hear that it is not working for you.

    The smst demo includes coffeescript: http://novocaine.github.io/sourcemapped-stacktrace-demo/public_html/smst.html

    I'm not sure the regex itself is the problem, as this works for me:

    x = "    at stack (https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1201:27)"
    regex = /^ +at.+\((.*):([0-9]+):([0-9]+)/;
    x.match(regex)
    ["    at stack (https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1201:27", "https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js", "1201", "27"]
    

    Perhaps you could try to work out what is working correctly in the demo's coffeescript processing that isn't working for you?

    Or put a jsfiddle or similar up reproducing the issue? Not sure how else I can help debug from afar.

  2. dgoldstein0 commented on Jul 9, 2016

    @dgoldstein0
    Author

    That particular stack line - for the coffeescript file - has no parentheses
    in it. I don't know how chrome decides to format it's stacks, but that's
    what it gave me.

    I guess I should check what version of chrome I'm using.

    On Sat, Jul 9, 2016, 1:18 AM James Salter notifications@github.com wrote:

    Hi,

    Sorry to hear that it is not working for you.

    The smst demo includes coffeescript:
    http://novocaine.github.io/sourcemapped-stacktrace-demo/public_html/smst.html

    I'm not sure the regex itself is the problem, as this works for me:

    x = " at stack (https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1201:27)"
    regex = /^ +at.+((.*):([0-9]+):([0-9]+)/;
    x.match(regex)
    [" at stack (https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1201:27", "https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js", "1201", "27"]

    Perhaps you could try to work out what is working correctly in the demo's
    coffeescript processing that isn't working for you?

    —
    You are receiving this because you authored the thread.
    Reply to this email directly, view it on GitHub
    #16 (comment),
    or mute the thread
    https://github.com/notifications/unsubscribe/ABBnd3P5__kg616tN8A-_e8kr3oC4x2Xks5qT1lpgaJpZM4JIi3p
    .

  3. novocaine commented on Jul 10, 2016

    @novocaine
    Owner

    oh I see, your problem is with

    at https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/tests/jasmine_tests/example-vfl
    DEVHASH.js:5:24
    

    but the other lines are fine. Sorry I didn't grok that. Okay, I guess we need to adjust the line parser. Do you get the same issue in firefox? Are you able to provide me with example-vflDEVHASH.js?

  4. dgoldstein0 commented on Jul 10, 2016

    @dgoldstein0
    Author

    Right

    On Sun, Jul 10, 2016, 9:33 AM James Salter notifications@github.com wrote:

    oh I see, your problem is with

    at https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/tests/jasmine_tests/example-vfl
    DEVHASH.js:5:24

    but the other lines are fine. Okay, I guess we need to adjust the line
    parser.

    —
    You are receiving this because you authored the thread.
    Reply to this email directly, view it on GitHub
    #16 (comment),
    or mute the thread
    https://github.com/notifications/unsubscribe/ABBnd8nsCJy2xnUZKANsW9UT74pGLmLJks5qUR7ggaJpZM4JIi3p
    .

  5. novocaine commented on Jul 25, 2016

    @novocaine
    Owner

    Hey, sorry but I can't effectively fix this until you post the js source or the trace in firefox.

  6. dgoldstein0 commented on Aug 17, 2016

    @dgoldstein0
    Author

    I actually didn't keep that original test case around, so here's a new one that should repro it:

    /static/coffee/modules/example.test.coffee:

    define [], ->
      describe "example", ->
        it "fails", ->
          foo.bar
    

    compiles to /static/javascript/compiled/modules/example.test.js:

    // Generated by CoffeeScript 1.10.0
    (function() {
      define([], function() {
        return describe("example", function() {
          return it("fails", function() {
            return foo.bar;
          });
        });
      });
    
    }).call(this);
    
    //# sourceMappingURL=example.test.js.map
    

    sourcemap /static/javascript/compiled/modules/example.test.js.map:

    {
      "version": 3,
      "file": "example.test.js",
      "sourceRoot": "../../../coffee",
      "sources": [
        "modules/example.test.coffee"
      ],
      "names": [],
      "mappings": ";AAAA;EAAA,MAAA,CAAO,EAAP,EAAW,SAAA;WACT,QAAA,CAAS,SAAT,EAAoB,SAAA;aAClB,EAAA,CAAG,OAAH,EAAY,SAAA;eACV,GAAG,CAAC;MADM,CAAZ;IADkB,CAApB;EADS,CAAX;AAAA"
    }
    

    When I run this under jasmine in Chrome, I get this stack trace:

        ReferenceError: foo is not defined
        at https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/modules/example.test.js:6:16
        at Object.arguments.(anonymous function) (https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine-promises-vflDEVHASH.js:71:47)
        at attemptAsync (https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1501:32)
        at QueueRunner.run (https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1456:17)
        at QueueRunner.execute (https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1449:14)
        at Spec.queueRunnerFactory (https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:504:41)
        at Spec.execute (https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:283:14)
        at Object.fn (https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1934:30)
        at attemptAsync (https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1501:32)
        at QueueRunner.run (https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1456:17)"
    

    And with Firefox I end up with a much longer stack trace with weirder issues:

    @https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/modules/example.test.js:6:9
    patchFunction/obj[slot]/arguments[fnArgIndex]@https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine-promises-vflDEVHASH.js:71:47
    attemptAsync@https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1501:17
    QueueRunner.prototype.run@https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1456:17
    QueueRunner.prototype.execute@https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1449:9
    Env/queueRunnerFactory@https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:504:13
    Spec.prototype.execute@https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:283:1
    executeNode/<.fn@https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1934:25
    attemptAsync@https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1501:17
    QueueRunner.prototype.run@https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1456:17
    QueueRunner.prototype.execute@https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1449:9
    Env/queueRunnerFactory@https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:504:13
    executeNode/<.fn@https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1918:1
    attemptAsync@https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1501:17
    QueueRunner.prototype.run@https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1456:17
    QueueRunner.prototype.execute@https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1449:9
    Env/queueRunnerFactory@https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:504:13
    TreeProcessor/this.execute@https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:1808:1
    Env/this.execute@https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/jasmine-vflDEVHASH.js:547:13
    window.onload@https://cf-servervm2.dev.corp.dropboxstatic.com/static/javascript/compiled/external/jasmine/boot-vflDEVHASH.js:58:9
    ... (code loading from requirejs down this way, omitted for brevity)
    

    in both cases the first line is not properly handled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions