-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support a "capping required" mode of operation; or allow reporting unheard rejections. #23
Comments
This has been on the back of my mind for a while. Tracking resolved/unresolved promises is also good for what you did earlier for waterfall analysis. We definitely need something, perhaps the ability to create Q sandbox instances that can create a report of the outstanding promise graph.
I'll be away for a week, so I will probably not be able to have a lively discussion for a while. That said, I do want to have more dialog with friends and supporters. We need to be a more tightly knit group and I need to be more conscious of how Q is being used in the wild. |
Sandboxes and support for annotations would be excellent, although I should be clear that my biggest concern in this issue is that use of Q can lead to quietly eaten exceptions. The Mozilla platform (at least when dealing with the non-browser XPCOM stuff) loves to eat exceptions, and I don't want to go back to that, so it would be great to make sure that rejections (that are exceptions, at least) are always re-thrown if not explicitly handled by the user. In any event, Q is working fantastically for me, especially with a minor hack patch to re-throw errors. Thanks again for all the great work on Q, have a good week away/off, and let me know if there's a mailing list you would like to use to discuss such issues. (The XPCOM issue in a nutshell, if you are interested, is a 1) fundamental impedance mismatch between C++ and (transparently-exposed) JS and 2) the use of integer success/error codes in the C++ code. The XPConnect code allows JS code to obey the C++-style IDL interfaces, but has a hard call to make when an exception propagates upward, because it is able to translate the exception to an integer failure code, which may or may not be desired... it can't tell and can only either report every exception it sees or just translate them to integers. Unfortunately, that sucks quite extensively for developers. Q is in the much more advantageous position of being able to tell that there is no one explicitly handling/translating an error, and thus that it can/should be reported.) |
I believe issue 30, #30, is a example of the problem being discussed here. |
This came up in volo too, and recently saw a link to domains in node which sounds similar to the pool approach that @kriskowal mentioned. I do not have anything helpful to add, just mentioning data points. |
WinJS has a similar solution to Q, where
The latter has a particularly poignant quote:
In practice, we've adapted to the status quo, and adopt the simple rule to always either (a) return the promise; or (b) cap with |
However, I still think there would be value in introducing promise |
It’s time to put this issue to bed. There are three directions being pursued.
Thanks, @asutherland. This is the longest lasting, most relevant issue we have. |
Although I try very hard to avoid letting success values or rejections fall on the floor, I keep screwing up, and it seems like Q could help make it more obvious when I am screwing up.
The defer() resolve() implementation knows when it is being resolved with no one around to hear because pending will be empty. I propose adding some kind of optional reporting in this case. This would allow my testing framework to both notice when:
Obviously, there needs to be a way to actually "cap" the chain of promises. The current end() method does this in spirit, but I believe will still result in resolutions with an undefined value. (OTOH, undefined could just be made special in that it does not trigger the reporting logic.)
I recognize that there are two use-cases that would not be happy about this happening all the time:
The solution to both those problems is that this would be opt-in. Either you could provide a custom handler, or invoke "$Q.forBabies()" which would just throw, thereby relying on node's/the browser's built-in stuff.
The text was updated successfully, but these errors were encountered: