Skip to content

Commit

Permalink
Strengthen native promise checks
Browse files Browse the repository at this point in the history
This change additionally checks that both Promise and Promise.toString
are implemented natively when determining whether promises should
be patched.

Fixes: #123
  • Loading branch information
Matt Loring committed Sep 12, 2017
1 parent 9c0f9ea commit c40482d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,11 @@ if (crypto) {
);
}

var instrumentPromise = !!global.Promise;
// It is unlikely that any userspace promise implementations have a native
// implementation of both Promise and Promise.toString.
var instrumentPromise = !!global.Promise &&
Promise.toString() === 'function Promise() { [native code] }' &&
Promise.toString.toString() === 'function toString() { [native code] }';

// Check that global Promise is native
if (instrumentPromise) {
Expand Down

0 comments on commit c40482d

Please sign in to comment.