Closed Bug 966462 Opened 10 years ago Closed 8 years ago

DOM Promises should dump "coding" exceptions thrown by handlers to the output (like Promise.jsm)

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: Paolo, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [Async])

DOM Promises should immediately dump to the output some types of exceptions that may be thrown by handlers registered with "then", in particular EvalError, RangeError, ReferenceError, and TypeError.

This serves a different purpose than the delayed Console reporting in bug 966452, as this one is done immediately. It is particularly useful when debugging xpcshell tests that use Tasks, because the error is written synchronously to the output.

This reporting is not visible by default in release builds.

STEPS TO REPRODUCE:
- Launch Nightly from a terminal window.
- Open the Web Console (CTRL+SHIFT+K)
- Type Promise.resolve().then(() => a.b);

ACTUAL RESULTS:
- No error message appears.

EXPECTED RESULTS:
- To compare with Promise.jsm, open the Browser Console (CTRL+SHIFT+J)
- Type Components.utils.import("resource://gre/modules/Promise.jsm");
- Type Promise.resolve().then(() => a.b);

An error messages appears in the window from which Firefox was launched:
- Informative explanation ("A coding exception was thrown in a Promise resolution callback.")
- Error message ("ReferenceError: a is not defined")
- Stack trace
Do we really want to dump this even if there is a rejection handler?  After all, we don't dump out caught JS exceptions!
(In reply to Boris Zbarsky [:bz] from comment #1)
> Do we really want to dump this even if there is a rejection handler?  After
> all, we don't dump out caught JS exceptions!

I agree that if we have full reporting on GC, this may be less important. It's more useful for Task exceptions (that are covered independently in Task.jsm) and is very useful in regression tests, so it could be implemented behind a test-only preference.
Whiteboard: [Async]
No longer blocks: 939636
(In reply to :Paolo Amadini from comment #0)
> DOM Promises should immediately dump to the output some types of exceptions
> that may be thrown by handlers registered with "then", in particular
> EvalError, RangeError, ReferenceError, and TypeError.
> 
> This serves a different purpose than the delayed Console reporting in bug
> 966452, as this one is done immediately. It is particularly useful when
> debugging xpcshell tests that use Tasks, because the error is written
> synchronously to the output.

Given that now we have a more reliable rejection reporting mechanism than the one on garbage collection, and that this feature doesn't block removing Promise.jsm anyways, I think we can WONTFIX this bug.

Dumping this type of exceptions even if caught can be a general purpose debugging feature.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → WONTFIX
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.