Skip to content

Commit 1e8a890

Browse files
committed
fix v8 6.6 (Node 10 and Chrome 66) Promise bug with resolving custom thenables
1 parent 3520378 commit 1e8a890

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

modules/es6.promise.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ var task = require('./_task').set;
1313
var microtask = require('./_microtask')();
1414
var newPromiseCapabilityModule = require('./_new-promise-capability');
1515
var perform = require('./_perform');
16+
var userAgent = require('./_user-agent');
1617
var promiseResolve = require('./_promise-resolve');
1718
var PROMISE = 'Promise';
1819
var TypeError = global.TypeError;
1920
var process = global.process;
21+
var versions = process && process.versions;
22+
var v8 = versions && versions.v8 || '';
2023
var $Promise = global[PROMISE];
2124
var isNode = classof(process) == 'process';
2225
var empty = function () { /* empty */ };
@@ -31,7 +34,13 @@ var USE_NATIVE = !!function () {
3134
exec(empty, empty);
3235
};
3336
// unhandled rejections tracking support, NodeJS Promise without it fails @@species test
34-
return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise;
37+
return (isNode || typeof PromiseRejectionEvent == 'function')
38+
&& promise.then(empty) instanceof FakePromise
39+
// v8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
40+
// https://bugs.chromium.org/p/chromium/issues/detail?id=830565
41+
// we can't detect it synchronously, so just check versions
42+
&& v8.indexOf('6.6') !== 0
43+
&& userAgent.indexOf('Chrome/66') === -1;
3544
} catch (e) { /* empty */ }
3645
}();
3746

0 commit comments

Comments
 (0)