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

2.1.2 provoke TypeError: Cannot read property 'length' of undefined in es6-promise #176

Closed
cyrilgandon opened this issue Feb 29, 2016 · 8 comments

Comments

@cyrilgandon
Copy link

I create an issue in Karma, but my guess is it is more relevant here.
Karma related issue : karma-runner/karma#1946
es6-promise related issue : stefanpenner/es6-promise#169

Stack trace:

TypeError: Cannot read property 'length' of undefined
    at lib$es6$promise$$internal$$fulfill (.\node_modules\grunt-ts\node_modules\csproj2ts\node_modules\es6-promise\dist\es6-promise.js:273:31)
    at lib$es6$promise$$internal$$resolve (.\node_modules\grunt-ts\node_modules\csproj2ts\node_modules\es6-promise\dist\es6-promise.js:255:9)
    at lib$es6$promise$$internal$$invokeCallback (.\node_modules\grunt-ts\node_modules\csproj2ts\node_modules\es6-promise\dist\es6-promise.js:366:9)
    at .\node_modules\grunt-ts\node_modules\csproj2ts\node_modules\es6-promise\dist\es6-promise.js:891:13    
    at lib$es6$promise$asap$$flush (.\node_modules\grunt-ts\node_modules\csproj2ts\node_modules\es6-promise\dist\es6-promise.js:125:9)    
    at doNTCallback0 (node.js:408:9)
    at process._tickCallback (node.js:337:13)

This commit should have provoke the regression : 3b8292d#diff-ee864bf9a84ab105426dbe4fbbad2a69

But my knowledge of node.js is close to zero, so it's just a guess.

The stacktrace seems to lead to this particular line:
https://github.com/stefanpenner/es6-promise/blob/master/lib/es6-promise/-internal.js#L127

As both es6-promise and core-js depend on nothing, I bet that error occured when both are called from other libraries, like in my case, grunt-ts(depends on es6-promise) and karma(depends on core-js).

I also bet that one overwrites global stuff from the other, which explains why error occured when both are called from the same process, and not when they are called one task after the other on different process.

@thomastardy
Copy link

Facing the same issue

@oliversommer
Copy link

for me it's related to core-js which is a transitive dependency of karma. I pinned core-js at 2.1.1 and this way it works for me. at least a quick fix.

@zloirock
Copy link
Owner

It's a bug in es6-promise. In feature detection, core-js detected @@species constructor pattern support in Promise#then. es6-promise not supports it and throws an error. Feature detection wrapped in try / catch, but an error throws async.

@zloirock
Copy link
Owner

Reproducible example:

require('es6-promise');
var p = Promise.resolve();
p.constructor = function(it){ it(function(){}, function(){})};
p.constructor[Symbol.species] = function(it){ it(function(){}, function(){})};

try {
  var f = p.then(function(){});
  console.log('works: ', f instanceof p.constructor[Symbol.species]);
} catch(e){
  console.log('caught error');
}

@zloirock
Copy link
Owner

I will add a fallback for this buggy implementation, need to think how.

@zloirock
Copy link
Owner

In 2.1.3 added a fallback for this es6-promise bug.

@cyrilgandon
Copy link
Author

Thank you @zloirock for your hard work! 👍

@stefanpenner
Copy link

Es6-promise should also no longer cause this crash

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

No branches or pull requests

5 participants