Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No source mapping for async functions #92

Open
Bjvanminnen opened this issue Jun 1, 2015 · 6 comments
Open

No source mapping for async functions #92

Bjvanminnen opened this issue Jun 1, 2015 · 6 comments

Comments

@Bjvanminnen
Copy link

When hitting assertions in asynchronous code, we don't get unhelpful callstacks, instead just getting the line number from bundle.js

var assert = require('chai').assert;

describe('foo', function () {
  it('sync', function (done) {
    assert(true, 'truth');
    assert(false, 'false');
  });

  it('async', function (done) {
    assert(true, 'truth');

    setTimeout(function () {
      assert(false, 'false');
      done();
    }, 1000);
  });
});

Result:

1) foo sync:                                                            
   false                                                                
    at assert (node_modules/chai/lib/chai/assertion.js:111:67)          
    at assert (node_modules/chai/lib/chai/interface/assert.js:37:16)    
    at test/test.js:6:11                                                

2) foo async:                                                           
   Uncaught AssertionError: false (http://localhost:52436/js/bundle:229)
@mantoni
Copy link
Owner

mantoni commented Jun 2, 2015

Yes, I'm seeing this occasionally as well. Not sure it has something to do with the async test case.

Can you try and run the tests as a website with --consolify and check whether you see the same thing? Maybe even in different browsers?

@Bjvanminnen
Copy link
Author

Chrome on OSX

  1) foo sync:
     AssertionError: false
      at Context.<anonymous> (test/test.js:6:5)
      at Test.Runnable.run (node_modules/mochify/node_modules/mocaccino/lib/setup-browser.js:4529:15)
      at Runner.runTest (node_modules/mochify/node_modules/mocaccino/lib/setup-browser.js:4974:10)
      at node_modules/mochify/node_modules/mocaccino/lib/setup-browser.js:5057:12
      at next (node_modules/mochify/node_modules/mocaccino/lib/setup-browser.js:4899:14)
      at node_modules/mochify/node_modules/mocaccino/lib/setup-browser.js:4909:7
      at next (node_modules/mochify/node_modules/mocaccino/lib/setup-browser.js:4844:23)
      at node_modules/mochify/node_modules/mocaccino/lib/setup-browser.js:4876:5
      at timeslice (node_modules/mochify/node_modules/mocaccino/lib/setup-browser.js:6483:27)

  2) foo async:
     Uncaught Uncaught AssertionError: false (file:///Users/brent/git/fun/mochify_test/output.html:389)
      Error: Uncaught AssertionError: false (node_modules/chai/lib/chai/assertion.js:107)
      at global.onerror (node_modules/mochify/node_modules/mocaccino/lib/setup-browser.js:6458:10)

Firefox

  1) foo sync:
     false


  2) foo async:
     Uncaught AssertionError: false (:0)
      require<[88]</</process.on/global.onerror node_modules/mochify/node_modules/mocaccino/lib/setup-browser.js:6458:10

Safari

1) foo sync:
     false
      assert node_modules/chai/lib/chai/assertion.js:111:67
      assert node_modules/chai/lib/chai/interface/assert.js:37:16
      test/test.js:6:11
      run node_modules/mochify/node_modules/mocaccino/lib/setup-browser.js:4529:19
      runTest node_modules/mochify/node_modules/mocaccino/lib/setup-browser.js:4974:13
      node_modules/mochify/node_modules/mocaccino/lib/setup-browser.js:5057:19
      next node_modules/mochify/node_modules/mocaccino/lib/setup-browser.js:4899:16
      node_modules/mochify/node_modules/mocaccino/lib/setup-browser.js:4909:11
      next node_modules/mochify/node_modules/mocaccino/lib/setup-browser.js:4844:25
      node_modules/mochify/node_modules/mocaccino/lib/setup-browser.js:4876:9
      timeslice node_modules/mochify/node_modules/mocaccino/lib/setup-browser.js:6483:27

  2) foo async:
     Uncaught AssertionError: false (file:///Users/brent/git/fun/mochify_test/output.html:393)
      onerror node_modules/mochify/node_modules/mocaccino/lib/setup-browser.js:6458:19

@boneskull
Copy link
Collaborator

try mocha's --full-trace option. we eliminated much of the stack trace to ignore Mocha internals; maybe it's zapping lines it shouldn't.

@boneskull
Copy link
Collaborator

I'm running into this.

@boneskull
Copy link
Collaborator

I don't even know if the browser bundle of mocha supports full-trace

@mantoni
Copy link
Owner

mantoni commented Nov 12, 2015

I suppose this happens because errors in async functions are caught with the window "error" event. Mocha then associates the error with the currently running test. Unfortunately, browsers treat these "global" errors very differently and it's not guaranteed that there is a stack trace at all.

To anyone who wants to look into this, I'd suggest to check what the raw format of a global error looks like in different browsers / phantom and then fix that RegExp in source-mapper.

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

No branches or pull requests

3 participants