paulmillr / es6-shim

ECMAScript 6 compatibility shims for legacy JS engines
http://paulmillr.com
MIT License
3.11k stars 387 forks source link

Chrome logs 'Uncaught (in promise) TypeError' on load #403

Closed baardsen closed 8 years ago

baardsen commented 8 years ago

Chrome dev (49.0.2623.23) logs an error to console when loading es6-shim. chromeerror

The error seems to come from the promiseResolveBroken test:

var promiseResolveBroken = (function (Promise) {
  var p = Promise.resolve(5);
  p.constructor = {};
  var p2 = Promise.resolve(p);
  return (p === p2); // This *should* be false!
}(globals.Promise));

One possible fix is to add an empty reject handler to the p2 promise:

if (p2.then)
  p2.then(function() {}, function() {});`
ljharb commented 8 years ago

Generally speaking, warnings like this aren't something that need "fixing" - Firefox logs a warning about mutating prototypes, for example, because one of es6-shim's runtime checks needs to try to mutate a prototype to check compliance.

However, in this case, something like the fix you've suggested will indeed work - thanks for the suggestion!

zloirock commented 8 years ago

Just for info: https://github.com/zloirock/core-js/issues/159 / https://code.google.com/p/chromium/issues/detail?id=575314