Open
Bug 1478076
Opened 6 years ago
Updated 2 years ago
[jsdbg2] Debugger needs way to mark a promise as 'caught'
Categories
(Core :: JavaScript Engine, defect, P3)
Core
JavaScript Engine
Tracking
()
NEW
People
(Reporter: jimb, Assigned: jimb)
References
(Blocks 1 open bug)
Details
A Debugger.Object referring to a promise should provide a method to mark that promise as 'caught', so that if it is rejected, it does not cause a warning/error to be logged at the end of the tick.
As described in bug 1477765, in the process of displaying an objct, the server often applies native getters it finds on the object's prototype chain. If one inspects a prototype object directly, these getters are applied to the prototype itself, and often raise an error. To detect this case, methods like ObjectActor._findSafeGetterValues check for { throw: X } completion values from the getter application.
However, some accessors return promises of a value, and return a rejected promise when applied to an object of the wrong type (like a prototype object). If not marked as 'caught', these promises will log an error. Debugger.Object provides methods for recognizing promises and detecting that they are rejected, but no method for marking the promise as caught. This seems like a reasonable thing to do for promises generated as a result of the debugger's own activity.
The workaround is to say obj.unsafeDereference().catch(e => e), but that's unsafe in general.
Comment 1•6 years ago
|
||
Thanks for filing. Is this something you could take, Jim? Bug 1477765 is blocking Bug 1475342, which I'd like to get landed.
Flags: needinfo?(jimb)
Assignee | ||
Comment 2•6 years ago
|
||
Yes, I can take this. I'm on PTO next week, and I have a bunch of reviews to get through before then, though. So, anyone else should feel free to steal this.
Assignee: nobody → jimb
Flags: needinfo?(jimb)
Assignee | ||
Comment 3•6 years ago
|
||
As explained in bug 1477765 comment 28, I don't think this is actually the right feature to address the situation that led to filing this bug. But in case we want it anyway, here's the doc text I wrote in the course of trying to think it through:
`forcePromiseHandled()`
: If the referent is a promise, then mark it as having been handled.
Many objects implementing parts of the web platform expose critical
information via accessor properties; for example, a mouse click event's `x`
and `y` properties are only available via accessors the event object
inherits from its prototype. To provide a meaningful view of such an object,
developer tool user interfaces must try to identify accessors that are free
of side effects, and apply them tentatively to the object under inspection.
Most such accessors throw an exception if they are applied to an object of
the wrong type (say, the prototype object that owns them); this exception is
reflected in the accessor call's completion value, which the developer tools
can detect and handle appropriately. However, some properties designed to be
used asynchronously return a rejected promise instead. Rejected promises
left unhandled may log their error, to avoid burying potentially helpful
error messages.
As a result, if developer tools are to avoid generating spurious error
reports in the course of inspection meant to be invisible, they must
recognize such promises and mark them as caught. This method allows them to
do that.
Assignee | ||
Comment 4•6 years ago
|
||
(That'd go in js/src/doc/Debugger/Debugger.Object.md.)
Updated•6 years ago
|
Priority: -- → P3
Updated•4 years ago
|
Blocks: js-debugger
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•