Console hooks #65

Closed
kriskowal opened this Issue May 2, 2012 · 5 comments

Comments

Projects
None yet
3 participants
Owner

kriskowal commented May 2, 2012

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:

console.deferred(deferred);
console.resolved(promise);
console.fulfilled(promise);
console.rejected(promise);
Collaborator

domenic commented May 2, 2012

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?

Owner

kriskowal commented May 2, 2012

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.

Collaborator

ForbesLindesay commented May 3, 2012

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.

Owner

kriskowal commented May 3, 2012

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

@kriskowal kriskowal closed this Oct 20, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment