From b0640946873945ee95d2cab8f549c915dbfffd70 Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Thu, 7 Jan 2016 09:30:14 -0800 Subject: [PATCH] Add support for promise rejection tracking Summary: Adds support for tracking unhandled rejections with `console.warn` (= yellow box). I will create a follow-up with proper error stack formatting. related: #4971 fixes: #4045, #4142 public {F59857438} {F59857439} Reviewed By: bestander Differential Revision: D2803126 fb-gh-sync-id: 376b33e42a967675a04338cbff3ec315a77d1037 --- Libraries/Promise.js | 20 +++++ npm-shrinkwrap.json | 202 +++++++++++++++++++++---------------------- package.json | 2 +- 3 files changed, 122 insertions(+), 102 deletions(-) diff --git a/Libraries/Promise.js b/Libraries/Promise.js index 7cef2042332edc..004741948e4d14 100644 --- a/Libraries/Promise.js +++ b/Libraries/Promise.js @@ -25,6 +25,26 @@ global.setImmediate = require('setImmediate'); var Promise = require('promise/setimmediate/es6-extensions'); require('promise/setimmediate/done'); +if (__DEV__) { + require('promise/setimmediate/rejection-tracking').enable({ + allRejections: true, + onUnhandled: (id, error) => { + const {message, stack} = error; + const warning = + `Possible Unhandled Promise Rejection (id: ${id}):\n` + + (message == null ? '' : `${message}\n`) + + (stack == null ? '' : stack); + console.warn(warning); + }, + onHandled: (id) => { + const warning = + `Promise Rejection Handled (id: ${id})\n` + + 'This means you can ignore any previous messages of the form ' + + `"Possible Unhandled Promise Rejection (id: ${id}):"`; + console.warn(warning); + }, + }); +} /** * Handle either fulfillment or rejection with the same callback. diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 9cc1229db7cc1c..be4e7c0d843e83 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -146,16 +146,16 @@ "version": "2.2.0", "from": "debug@>=2.1.1 <3.0.0" }, - "globals": { - "version": "6.4.1", - "from": "globals@>=6.4.0 <7.0.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-6.4.1.tgz" - }, "js-tokens": { "version": "1.0.1", "from": "js-tokens@1.0.1", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-1.0.1.tgz" }, + "globals": { + "version": "6.4.1", + "from": "globals@>=6.4.0 <7.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-6.4.1.tgz" + }, "recast": { "version": "0.10.33", "from": "recast@0.10.33", @@ -264,26 +264,26 @@ } } }, - "ast-types": { - "version": "0.8.12", - "from": "ast-types@0.8.12", - "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.8.12.tgz" - }, - "globals": { - "version": "6.4.1", - "from": "globals@>=6.4.0 <7.0.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-6.4.1.tgz" - }, "babylon": { "version": "5.8.29", "from": "babylon@>=5.8.29 <6.0.0", "resolved": "https://registry.npmjs.org/babylon/-/babylon-5.8.29.tgz" }, + "ast-types": { + "version": "0.8.12", + "from": "ast-types@0.8.12", + "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.8.12.tgz" + }, "esprima-fb": { "version": "15001.1001.0-dev-harmony-fb", "from": "esprima-fb@>=15001.1001.0-dev-harmony-fb <15001.1002.0", "resolved": "https://registry.npmjs.org/esprima-fb/-/esprima-fb-15001.1001.0-dev-harmony-fb.tgz" }, + "globals": { + "version": "6.4.1", + "from": "globals@>=6.4.0 <7.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-6.4.1.tgz" + }, "js-tokens": { "version": "1.0.1", "from": "js-tokens@1.0.1", @@ -1869,46 +1869,46 @@ "from": "ansi-regex@^2.0.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz" }, - "are-we-there-yet": { - "version": "1.0.4", - "from": "are-we-there-yet@~1.0.0", - "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.0.4.tgz" - }, "ansi-styles": { "version": "2.1.0", "from": "ansi-styles@^2.1.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.1.0.tgz" }, + "are-we-there-yet": { + "version": "1.0.4", + "from": "are-we-there-yet@~1.0.0", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.0.4.tgz" + }, "asn1": { "version": "0.1.11", "from": "asn1@0.1.11", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.1.11.tgz" }, - "async": { - "version": "1.5.0", - "from": "async@^1.4.0", - "resolved": "https://registry.npmjs.org/async/-/async-1.5.0.tgz" - }, "assert-plus": { "version": "0.1.5", "from": "assert-plus@^0.1.5", "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.1.5.tgz" }, + "async": { + "version": "1.5.0", + "from": "async@^1.4.0", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.0.tgz" + }, "aws-sign2": { "version": "0.6.0", "from": "aws-sign2@~0.6.0", "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz" }, - "block-stream": { - "version": "0.0.8", - "from": "block-stream@*", - "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.8.tgz" - }, "balanced-match": { "version": "0.2.1", "from": "balanced-match@>=0.2.0 <0.3.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.2.1.tgz" }, + "block-stream": { + "version": "0.0.8", + "from": "block-stream@*", + "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.8.tgz" + }, "boom": { "version": "2.10.1", "from": "boom@^2.8.x", @@ -1929,16 +1929,16 @@ "from": "chalk@^1.1.1", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.1.tgz" }, - "commander": { - "version": "2.9.0", - "from": "commander@^2.8.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz" - }, "combined-stream": { "version": "1.0.5", "from": "combined-stream@~1.0.5", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz" }, + "commander": { + "version": "2.9.0", + "from": "commander@^2.8.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz" + }, "concat-map": { "version": "0.0.1", "from": "concat-map@0.0.1", @@ -1949,16 +1949,16 @@ "from": "core-util-is@~1.0.0", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz" }, - "ctype": { - "version": "0.5.3", - "from": "ctype@0.5.3", - "resolved": "https://registry.npmjs.org/ctype/-/ctype-0.5.3.tgz" - }, "cryptiles": { "version": "2.0.5", "from": "cryptiles@2.x.x", "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz" }, + "ctype": { + "version": "0.5.3", + "from": "ctype@0.5.3", + "resolved": "https://registry.npmjs.org/ctype/-/ctype-0.5.3.tgz" + }, "debug": { "version": "0.7.4", "from": "debug@~0.7.2", @@ -1969,16 +1969,16 @@ "from": "deep-extend@~0.2.5", "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.2.11.tgz" }, - "delegates": { - "version": "0.1.0", - "from": "delegates@^0.1.0", - "resolved": "https://registry.npmjs.org/delegates/-/delegates-0.1.0.tgz" - }, "delayed-stream": { "version": "1.0.0", "from": "delayed-stream@~1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz" }, + "delegates": { + "version": "0.1.0", + "from": "delegates@^0.1.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-0.1.0.tgz" + }, "escape-string-regexp": { "version": "1.0.3", "from": "escape-string-regexp@^1.0.2", @@ -2029,26 +2029,26 @@ "from": "graceful-readlink@>= 1.0.0", "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz" }, - "has-ansi": { - "version": "2.0.0", - "from": "has-ansi@^2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz" - }, "har-validator": { "version": "2.0.2", "from": "har-validator@~2.0.2", "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-2.0.2.tgz" }, - "hawk": { - "version": "3.1.0", - "from": "hawk@~3.1.0", - "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.0.tgz" + "has-ansi": { + "version": "2.0.0", + "from": "has-ansi@^2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz" }, "has-unicode": { "version": "1.0.1", "from": "has-unicode@^1.0.0", "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-1.0.1.tgz" }, + "hawk": { + "version": "3.1.0", + "from": "hawk@~3.1.0", + "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.0.tgz" + }, "hoek": { "version": "2.16.3", "from": "hoek@2.x.x", @@ -2064,16 +2064,16 @@ "from": "inherits@*", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" }, - "is-my-json-valid": { - "version": "2.12.2", - "from": "is-my-json-valid@^2.12.2", - "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.12.2.tgz" - }, "ini": { "version": "1.3.4", "from": "ini@~1.3.0", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz" }, + "is-my-json-valid": { + "version": "2.12.2", + "from": "is-my-json-valid@^2.12.2", + "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.12.2.tgz" + }, "is-property": { "version": "1.0.2", "from": "is-property@^1.0.0", @@ -2084,21 +2084,26 @@ "from": "isarray@0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" }, - "json-stringify-safe": { - "version": "5.0.1", - "from": "json-stringify-safe@~5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz" - }, "isstream": { "version": "0.1.2", "from": "isstream@~0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz" }, + "json-stringify-safe": { + "version": "5.0.1", + "from": "json-stringify-safe@~5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz" + }, "jsonpointer": { "version": "2.0.0", "from": "jsonpointer@2.0.0", "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-2.0.0.tgz" }, + "lodash._basetostring": { + "version": "3.0.1", + "from": "lodash._basetostring@^3.0.0", + "resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz" + }, "lodash._createpadding": { "version": "3.6.1", "from": "lodash._createpadding@^3.0.0", @@ -2109,11 +2114,6 @@ "from": "lodash.pad@^3.0.0", "resolved": "https://registry.npmjs.org/lodash.pad/-/lodash.pad-3.1.1.tgz" }, - "lodash._basetostring": { - "version": "3.0.1", - "from": "lodash._basetostring@^3.0.0", - "resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz" - }, "lodash.padleft": { "version": "3.1.1", "from": "lodash.padleft@^3.0.0", @@ -2149,16 +2149,16 @@ "from": "mkdirp@>=0.3.0 <0.4.0||>=0.4.0 <0.5.0||>=0.5.0 <0.6.0", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz" }, - "npmlog": { - "version": "1.2.1", - "from": "npmlog@~1.2.0", - "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-1.2.1.tgz" - }, "node-uuid": { "version": "1.4.3", "from": "node-uuid@~1.4.3", "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.3.tgz" }, + "npmlog": { + "version": "1.2.1", + "from": "npmlog@~1.2.0", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-1.2.1.tgz" + }, "oauth-sign": { "version": "0.8.0", "from": "oauth-sign@~0.8.0", @@ -2179,16 +2179,16 @@ "from": "pinkie@^1.0.0", "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-1.0.0.tgz" }, - "qs": { - "version": "5.2.0", - "from": "qs@~5.2.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-5.2.0.tgz" - }, "pinkie-promise": { "version": "1.0.0", "from": "pinkie-promise@^1.0.0", "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-1.0.0.tgz" }, + "qs": { + "version": "5.2.0", + "from": "qs@~5.2.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-5.2.0.tgz" + }, "readable-stream": { "version": "1.1.13", "from": "readable-stream@^1.1.13", @@ -2199,56 +2199,56 @@ "from": "request@2.x", "resolved": "https://registry.npmjs.org/request/-/request-2.65.0.tgz" }, + "semver": { + "version": "5.0.3", + "from": "semver@~5.0.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.0.3.tgz" + }, "sntp": { "version": "1.0.9", "from": "sntp@1.x.x", "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz" }, - "stringstream": { - "version": "0.0.5", - "from": "stringstream@~0.0.4", - "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz" - }, "string_decoder": { "version": "0.10.31", "from": "string_decoder@~0.10.x", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" }, - "semver": { - "version": "5.0.3", - "from": "semver@~5.0.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.0.3.tgz" + "stringstream": { + "version": "0.0.5", + "from": "stringstream@~0.0.4", + "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz" }, "strip-ansi": { "version": "3.0.0", "from": "strip-ansi@^3.0.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.0.tgz" }, - "strip-json-comments": { - "version": "0.1.3", - "from": "strip-json-comments@0.1.x", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-0.1.3.tgz" - }, "supports-color": { "version": "2.0.0", "from": "supports-color@^2.0.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz" }, + "strip-json-comments": { + "version": "0.1.3", + "from": "strip-json-comments@0.1.x", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-0.1.3.tgz" + }, "tar": { "version": "2.2.1", "from": "tar@~2.2.0", "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz" }, - "tough-cookie": { - "version": "2.2.0", - "from": "tough-cookie@~2.2.0", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.2.0.tgz" - }, "tunnel-agent": { "version": "0.4.1", "from": "tunnel-agent@~0.4.1", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.1.tgz" }, + "tough-cookie": { + "version": "2.2.0", + "from": "tough-cookie@~2.2.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.2.0.tgz" + }, "uid-number": { "version": "0.0.3", "from": "uid-number@0.0.3", @@ -4139,9 +4139,9 @@ "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz" }, "promise": { - "version": "7.0.4", - "from": "promise@>=7.0.3 <8.0.0", - "resolved": "https://registry.npmjs.org/promise/-/promise-7.0.4.tgz", + "version": "7.1.1", + "from": "https://registry.npmjs.org/promise/-/promise-7.1.1.tgz", + "resolved": "https://registry.npmjs.org/promise/-/promise-7.1.1.tgz", "dependencies": { "asap": { "version": "2.0.3", diff --git a/package.json b/package.json index 37e7a79c1c4be6..e7faf110b16922 100644 --- a/package.json +++ b/package.json @@ -105,7 +105,7 @@ "opn": "^3.0.2", "optimist": "^0.6.1", "progress": "^1.1.8", - "promise": "^7.0.4", + "promise": "^7.1.1", "react": "^0.14.5", "react-timer-mixin": "^0.13.2", "react-transform-hmr": "^1.0.1",