-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incompatible with bluebird when set as global Promise. #121
Comments
Interesting. Async listener should not wrap non-native promises. I think there is a check for that, but it appears to not be working. I would look into making that check work, rather than trying to figure out how to wrapping bluebird promises. |
Rolling back my not be a bad idea in the mean time, I suspect that more people is bluebird is likely more popular than any library that subclasses promises |
@hayes Yes good idea, I'll roll back for now |
Does that mean async-listener is not supposed to work with non-native promises? Or just that non-native promises don't need wrapping for some reason? |
Non native promises are usually implemented using some other asynchronous api.to schedule work. This means that async listener hooks will already be fired. Some implementations I believe will implement their own queues and share async tasks from the real queues and execute multiple callbacks from their fake/custom task queues. In these cases it is likely/possible that async contexts could get confused. Async listener does not try to solve those types of issues (similar issues exist with connection pools), but consumers of the async listener API (apm agents, continuation-local-storage, etc) will generally add their own wrappers for these special cases. Often there is not a right way to handle these edge cases that applies to every use case, so the solution varies depending on what your using the app for |
@mrfelton it should work as it's just vanilla javascript, but bluebird might have custom callback queues that make it a little tricky depending on your use-case. Personally I've needed to modify bluebird slightly to work well for my needs. |
yes, @hayes explanation is spot on |
@mrfelton this have now been fixed in v0.6.7 |
Got it. Thanks for the detailed explanation @hayes . In my case, this module is being used as part of continuation-local-storage. |
You'll probably want to install https://www.npmjs.com/package/cls-bluebird |
Reopening because the fix was reverted due to an issue with bluebird |
Reopened the wrong issue |
When used with bluebird, this error is thrown:
Which comes from here: http://bluebirdjs.com/docs/error-explanations.html#error-the-promise-constructor-cannot-be-invoked-directly
Note there it says one of the causes of this is:
It seems that in [email protected], it is now attempting to subclass the global Promise. So, if global Promise has been set as Bluebird this fails. [email protected] does not suffer from this problem.
The text was updated successfully, but these errors were encountered: