Open medikoo opened 8 years ago
I just suffered from memoizee
using the .done
and me using Bluebird. Bluebird will do process.exit
inside .done
. http://bluebirdjs.com/docs/api/done.html "any unhandled rejection that ends up here will crash the process (in node)"
With bluebird one can use http://bluebirdjs.com/docs/api/reflect.html in order to find the resolved value without side effects.
Above was a reply to https://github.com/medikoo/memoizee/pull/59#issuecomment-232275536
@Rush Just setup memoization with promise: 'then'
option, and it'll be fine.
It's documented: https://github.com/medikoo/memoizee#promise-returning-functions
@Rush I've improved internal handling, so now by default when using Bluebird then:finally
mode will be used. done
mode is not recommended (and since v0.4.7 not applied by default) for reasons you mentioned (unconditional crashing in case of rejections)
@medikoo thank you! exciting
/cc @Kovensky
If used implementation doesn't implement
done
andfinally
then it's not possible to do both:The workaround could be, to provide a special mode for promise handling, in which user will agree that memoized function will return extended promise from original and not exactly one returned by original function.