GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Q should send messages to the console when promises are manipulated so that a monitor like a Causeway logger or Web Inspector view can be attached.
The corresponding console API is not defined. This is an idea to start the thinking process:
To make sure I understand, the idea is that we test for the presence of console.fulfilled, and if it exists, call it whenever a promise is fulfilled?
That’s the idea. The intention of the design, however, is to provide enough information to an optional external interface to produce useful debugging information for a running system, without entraining all of the interface logic in Q. This feature should be developed in tandem with some kind of waterfall or tree visualization, preferably with arrows connecting causes and effects and icons or colors denoting the state of each promise. Ideally we could get such an interface on track to be included in Web Inspector or Firebug.
Also, ideally this interface would be able to receive messages for remote events as well, but let’s not push it.
Would it be possible to listen for just rejections which happen with nobody to observe them? i.e. can you tell when a promise has been observed properly. If so then this would seem like a great plan, as you could very quickly write a basic system to ensure errors never go un-observed, and could build more complex (and awesome) debuggers later.
@tuskan360 the latest release already does this as a stopgap. It posts "Should be empty: " to the console log. This is a live array of all the rejections that have no handlers attached. When you create a rejection, the corresponding error gets added. When it is handled, it is removed from the array.
See also promises-aplus/unhandled-rejections-spec#2