-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
0.7.0 crashes when used with bluebird's coroutines and sourcemaps #289
Comments
AVA supports generators out of the box. No need to wrap with Test: test = require "ava"
delay = require "delay"
test "peter", (t) ->
yield delay 500 Output:
|
To me, this looks like a problem either with |
How is AVA able to transform the generator when it is handled by Leaving off the test = require "ava"
Promise = require "bluebird"
requestAsync = Promise.promisify require "request"
test "peter", (t) ->
yield requestAsync url: "www.google.com" This time, the error has no stack trace:
If I add |
Yes. The following works fine (needed the test = require "ava"
Promise = require "bluebird"
requestAsync = Promise.promisify require "request"
test "peter", (t) ->
yield requestAsync url: "http://www.google.com" Turning sourcemaps off gave a cleaner error message with source-maps off. Might be related: Also, googling @novemberborn - Do you have any insights here? |
All code examples in this thread are missing test('something', function * (t) {
yield requestAsync(...);
}); @alubbe let me know if that works! |
@vdemedes - These are all |
@jamestalmage oh, what a mess... |
Also, in these the This issue (choking on source-maps, and masking error messages that might be helpful), are really what bothers me. At a minimum |
@jamestalmage that PR seems like a good step to at least avoid not receiving any stack trace. I'll try and reproduce the issue, see if I can step through the |
The compiled coffee-script code means that there is no 0.7.0 contains #273 which passes an input source map to the Babel compiler used by AVA. If I disable the input source map I see this source map for Babel's output: { version: 3,
sources: [ '/private/var/folders/_6/p8qxp_3n62zg9081tvb0lcc80000gn/T/tmp.TAYPmrUt/test2.js' ],
names: [],
mappings: ';;;AACA,CAAC,YAAW;AACV,MAAI,OAAO,EAAE,IAAI,CAAC;;AAElB,MAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;;AAEtB,SAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;;AAE9B,MAAI,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,WAAU,CAAC,EAAE;AAC3C,WAAQ,MAAM,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAE;GACnC,CAAC,CAAC,CAAC;CAEL,CAAA,CAAE,IAAI,WAAM,CAAC',
file: '/private/var/folders/_6/p8qxp_3n62zg9081tvb0lcc80000gn/T/tmp.TAYPmrUt/test2.js',
sourcesContent: [ '// Generated by CoffeeScript 1.10.0\n(function() {\n var Promise, test;\n\n test = require("ava");\n\n Promise = require("bluebird");\n\n test("peter", Promise.coroutine(function*(t) {\n return (yield Promise.delay(500));\n }));\n\n}).call(this);\n\n//# sourceMappingURL=test2.js.map\n' ] } With the input source map I get: { version: 3,
sources: [ 'test2.coffee' ],
names: [],
mappings: ';;;AAAA,CAAA,YAAA;AAAA,MAAA,OAAA,EAAA,IAAA,CAAA;;AAAA,MAAA,GAAO,OAAA,CAAQ,KAAR,CAAA,CAAA;;AACP,SAAA,GAAU,OAAA,CAAQ,UAAR,CAAA,CAAA;;AAEV,MAAA,CAAK,OAAL,EAAc,OAAO,CAAC,SAAR,CAAkB,WAAC,CAAD,EAAA;ACM5B,WDLF,MAAM,OAAO,CAAC,KAAR,CAAc,GAAd,CAAN,CAAA;GADY,CAAd,CAAA,CAAA;CCSC,CAAA,CAAE,IAAI,WAAM,CAAC',
file: 'test2.js',
sourcesContent:
[ null,
'// Generated by CoffeeScript 1.10.0\n(function() {\n var Promise, test;\n\n test = require("ava");\n\n Promise = require("bluebird");\n\n test("peter", Promise.coroutine(function*(t) {\n return (yield Promise.delay(500));\n }));\n\n}).call(this);\n\n//# sourceMappingURL=test2.js.map\n' ] } Note that Turns out Bluebird throws an error when it's async module is loaded. This then causes a crash from This seems like a bug in Babel's handling of input source maps. Maybe it's already fixed in Babel 6. |
This is a
That is wrapped in a
That certainly seems like a bug. Can you submit an issue on the Babel tracker? (or hunt down an existing one and link it here).
Hopefully. The issue blocking our move to Babel 6 appears to finally be getting some traction. There is even a PR to fix it. |
It outputs
Ah yes that's the call to
I'm thoroughly confused regarding their code base and newfangled issue tracker, so that may be tricky. Even if it's not yet fixed in Babel 6 I doubt they'd backport any fixes? I'll see if I can reproduce the transformation with Babel 6 instead. That'll be a good start. |
Why do you think I punted this to you? Seriously though, the issue tracker is pretty straightforward once you dig in. As for the codebase, I feel your pain. I would recommend browsing a clean clone (don't run tests in the clean clone - it generates lots of additional sources that are just confusing until you get a basic grasp of the layout and build system). |
Transforming { version: 3,
file: 'test2.js',
sourceRoot: '',
sources: [ 'test2.coffee' ],
names: [],
mappings: ';AAAA,aAAA;MAAA;;AAAA,MAAA,GAAO,OAAA,CAAQ,KAAR;;AACP,SAAA,GAAU,OAAA,CAAQ,UAAR;;AAEV,MAAA,CAAK,OAAL,EAAc,OAAO,CAAC,SAAR,CAAkB,WAAC,CAAD;AAC9B,iBAAM,OAAO,CAAC,KAAR,CAAc,GAAd,CAAN,CAD8B;GAAlB,CAAd,EAHA' } If I force that into I found babel/babel@0ef6072 which links to babel/babel#2522 and babel/babel-loader#116 which discuss a similar "No element indexed by 1" error. Indeed when I inject a source map generated using Upgrading to Babel 6 should solve this issue. I suppose we could consider disabling input source maps but IMO that's not worth the trouble. (Can't find a corresponding issue in the Babel bugtracker though 😉) |
Good news, 0.9.x fixes this issue due to the new babel version! |
This simple test runs fine on 0.7.0 with source maps disabled and on 0.6.1 with source maps enabled, but crashes on 0.7.0 with source maps enabled:
The error is
With sourcemaps on, coffee produces
and
Source maps and 0.7.0 work fine on synchronous tests and on those returning a promise, maybe that helps in pinpointing the issue.
I'm using [email protected] and used this command to run the tests:
The text was updated successfully, but these errors were encountered: