Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Improve 'promise' mode with thenInjection option #60

Open
medikoo opened this issue Jul 13, 2016 · 4 comments
Open

Improve 'promise' mode with thenInjection option #60

medikoo opened this issue Jul 13, 2016 · 4 comments
Assignees

Comments

@medikoo
Copy link
Owner

medikoo commented Jul 13, 2016

/cc @Kovensky

If used implementation doesn't implement done and finally then it's not possible to do both:

  • Return promise as returned by original function
  • Register callbacks for internal use without muting eventual Unhandled error events.

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.

@Rush
Copy link

Rush commented Aug 1, 2016

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 #59 (comment)

@medikoo
Copy link
Owner Author

medikoo commented Aug 1, 2016

@Rush Just setup memoization with promise: 'then' option, and it'll be fine.
It's documented: https://github.com/medikoo/memoizee#promise-returning-functions

@medikoo
Copy link
Owner Author

medikoo commented Aug 29, 2017

@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)

@Rush
Copy link

Rush commented Aug 29, 2017

@medikoo thank you! exciting

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants