diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/memoize.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/memoize.js b/lib/memoize.js index 27c08bc..9ef871a 100644 --- a/lib/memoize.js +++ b/lib/memoize.js @@ -14,6 +14,9 @@ function has(obj, key) { * function results against, the callback is omitted from the hash and an * optional hash function can be used. * + * **Note: if the async function errs, the result will not be cached and + * subsequent calls will call the wrapped function.** + * * If no hash function is specified, the first argument is used as a hash key, * which may work reasonably if it is a string or a data type that converts to a * distinct string. Note that objects and arrays will not behave reasonably. @@ -63,7 +66,11 @@ export default function memoize(fn, hasher) { queues[key] = [callback]; _fn.apply(null, args.concat(function(/*args*/) { var args = slice(arguments); - memo[key] = args; + var err = args[0]; + // #1465 don't memoize if an error occurred + if (!err) { + memo[key] = args; + } var q = queues[key]; delete queues[key]; for (var i = 0, l = q.length; i < l; i++) { |