Subramanya Sastry has uploaded a new change for review. https://gerrit.wikimedia.org/r/171605
Change subject: Update prfun to 1.0.2 ...................................................................... Update prfun to 1.0.2 Change-Id: I8d0ab3bcaa2a1c4bd15660b565ac3965bfc13ffb --- M node_modules/prfun/CHANGELOG.md M node_modules/prfun/README.md M node_modules/prfun/lib/index.js M node_modules/prfun/package.json 4 files changed, 38 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid/deploy refs/changes/05/171605/1 diff --git a/node_modules/prfun/CHANGELOG.md b/node_modules/prfun/CHANGELOG.md index 8377de5..8aa4289 100644 --- a/node_modules/prfun/CHANGELOG.md +++ b/node_modules/prfun/CHANGELOG.md @@ -1,3 +1,7 @@ +# prfun 1.0.2 (2014-11-06) + +* Fix potential resource leak in `Promise#timeout`. + # prfun 1.0.1 (2014-09-25) * Added `Promise#tap`, `Promise#filter`. diff --git a/node_modules/prfun/README.md b/node_modules/prfun/README.md index f36650f..ae6833e 100644 --- a/node_modules/prfun/README.md +++ b/node_modules/prfun/README.md @@ -942,7 +942,24 @@ value will automatically skip the finally and propagate to further chainers. This is more in line with the synchronous `finally` keyword. -`Promise#finally` works like [Q's finally method](https://github.com/kriskowal/q/wiki/API-Reference#wiki-promisefinallycallback). +`Promise#finally` works like [Q's finally method](https://github.com/kriskowal/q/wiki/API-Reference#wiki-promisefinallycallback), unless `callback` returns a rejected promise. + +Note that the parallel with synchronous `finally` is not exact: +```js +// as expected: +(function() { try { return 1; } finally { throw "2"; } })(); // throws "2" +Promise.resolve(1).finally(function() { throw "2"; }); // rejects with "2" + +// but: +(function() { try { return 1; } finally { return 2; } })(); // returns 2 +Promise.resolve(1).finally(function() { return 2; }); // resolves to '1' + +// compare: +(function() { try { return 1; } finally { 2; } })(); // returns 1 +``` + +This asymmetry is because the `Promise` API can't distinguish the `return` +statement from an expression evaluating to a value. <hr> diff --git a/node_modules/prfun/lib/index.js b/node_modules/prfun/lib/index.js index 0773fb8..2b0cf61 100644 --- a/node_modules/prfun/lib/index.js +++ b/node_modules/prfun/lib/index.js @@ -289,12 +289,19 @@ }; TimeoutError.prototype = Object.create(Error.prototype); + var makeRejector = function(reject, message, ms) { + // create this function in an outer scope so that we don't inadvertently + // keep a reference to the promise here. Perhaps this is overkill. + var id = setTimeout(function() { reject(new TimeoutError(message)); }, ms); + return function() { clearTimeout(id); }; + }; Promise.prototype.timeout = function(ms, message) { var P = this.constructor || Promise; var promise = this; return new P(function(resolve, reject) { promise.then(resolve, reject); - setTimeout(function() { reject(new TimeoutError(message)); }, ms); + var cleanup = makeRejector(reject, message, ms); + promise.then(cleanup, cleanup); }); }; diff --git a/node_modules/prfun/package.json b/node_modules/prfun/package.json index ecfbf95..5375646 100644 --- a/node_modules/prfun/package.json +++ b/node_modules/prfun/package.json @@ -1,6 +1,6 @@ { "name": "prfun", - "version": "1.0.1", + "version": "1.0.2", "description": "Helper functions for ES6 promises", "main": "index.js", "scripts": { @@ -32,10 +32,10 @@ "dependencies": { "es6-shim": ">=0.10.0 <1.0.0-0" }, - "gitHead": "f992d2abda488fc6d207faea1554383173757639", - "_id": "[email protected]", - "_shasum": "4f396df1603dc1b95a5c378ec0a59c25c95af45b", - "_from": "prfun@", + "gitHead": "ea9b9b4bf46824d087a5dd5cbfb65466c2edff52", + "_id": "[email protected]", + "_shasum": "ac8799843d8194ea478ee4442e455fd5e054db3e", + "_from": "prfun@~1.0.1", "_npmVersion": "1.4.21", "_npmUser": { "name": "cscott", @@ -48,10 +48,10 @@ } ], "dist": { - "shasum": "4f396df1603dc1b95a5c378ec0a59c25c95af45b", - "tarball": "http://registry.npmjs.org/prfun/-/prfun-1.0.1.tgz" + "shasum": "ac8799843d8194ea478ee4442e455fd5e054db3e", + "tarball": "http://registry.npmjs.org/prfun/-/prfun-1.0.2.tgz" }, "directories": {}, - "_resolved": "https://registry.npmjs.org/prfun/-/prfun-1.0.1.tgz", + "_resolved": "https://registry.npmjs.org/prfun/-/prfun-1.0.2.tgz", "readme": "ERROR: No README data found!" } -- To view, visit https://gerrit.wikimedia.org/r/171605 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8d0ab3bcaa2a1c4bd15660b565ac3965bfc13ffb Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/parsoid/deploy Gerrit-Branch: master Gerrit-Owner: Subramanya Sastry <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
