Re: Use ".then(null, Cu.reportError);" with Promise.jsm

2013-08-09 Thread Boris Zbarsky

On 8/9/13 9:27 AM, Boris Zbarsky wrote:

I think we should definitely report to the error console.


I filed https://bugzilla.mozilla.org/show_bug.cgi?id=903419

-Boris
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Use ".then(null, Cu.reportError);" with Promise.jsm

2013-08-09 Thread David Rajchenbach-Teller
This definitely makes sense.
In the JS implementation, assuming main thread only, we should be able
to rig together a finalizer/warning using XPCOM.

Cheers,
 David


On 8/9/13 3:27 PM, Boris Zbarsky wrote:
> Well, the obvious other thing would be window.onerror.  But that might
> be tough, since making GC effects be page-observable is not great.
> 
> I think we should definitely report to the error console.
> 
> -Boris
> 
> ___
> dev-platform mailing list
> dev-platform@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-platform


-- 
David Rajchenbach-Teller, PhD
 Performance Team, Mozilla
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Use ".then(null, Cu.reportError);" with Promise.jsm

2013-08-09 Thread Anne van Kesteren
On Fri, Aug 9, 2013 at 2:27 PM, Boris Zbarsky  wrote:
> Well, the obvious other thing would be window.onerror.  But that might be
> tough, since making GC effects be page-observable is not great.

Yeah, I thought that would be out for precisely that reason.


> I think we should definitely report to the error console.

Seems like a nice trick indeed.


-- 
http://annevankesteren.nl/
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Use ".then(null, Cu.reportError);" with Promise.jsm

2013-08-09 Thread Boris Zbarsky

On 8/9/13 9:13 AM, Anne van Kesteren wrote:

On Fri, Aug 9, 2013 at 2:08 PM, Boris Zbarsky  wrote:

Oh, that is a _very_ interesting idea.  I wonder whether we can get that
specced, or at least allowed by the spec.


If it's just to the error console, we can do whatever we want. Do you
have something else in mind?


Well, the obvious other thing would be window.onerror.  But that might 
be tough, since making GC effects be page-observable is not great.


I think we should definitely report to the error console.

-Boris

___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Use ".then(null, Cu.reportError);" with Promise.jsm

2013-08-09 Thread Anne van Kesteren
On Fri, Aug 9, 2013 at 2:08 PM, Boris Zbarsky  wrote:
> Oh, that is a _very_ interesting idea.  I wonder whether we can get that
> specced, or at least allowed by the spec.

If it's just to the error console, we can do whatever we want. Do you
have something else in mind?


-- 
http://annevankesteren.nl/
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Use ".then(null, Cu.reportError);" with Promise.jsm

2013-08-09 Thread Boris Zbarsky

On 8/9/13 5:54 AM, Neil wrote:

(For instance I suspect it might be feasible for DOM promises
to report any pending exception when they get garbage collected.)


Oh, that is a _very_ interesting idea.  I wonder whether we can get that 
specced, or at least allowed by the spec.


-Boris

___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Use ".then(null, Cu.reportError);" with Promise.jsm

2013-08-09 Thread Neil

Paolo Amadini wrote:


This is a quick reminder to anyone writing or reviewing code that uses 
"Promise.jsm".
 

How do the other promise implementations in the tree compare in this 
respect? (For instance I suspect it might be feasible for DOM promises 
to report any pending exception when they get garbage collected.)


--
Warning: May contain traces of nuts.
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Use ".then(null, Cu.reportError);" with Promise.jsm

2013-08-09 Thread Paolo Amadini
This is a quick reminder to anyone writing or reviewing code that uses
"Promise.jsm".

You should check that exceptions aren't swallowed, and this is typically
done with a logging rejection handler. You should always use the handler
unless you're handing off the promise to other code. For some examples:

https://developer.mozilla.org/Mozilla/JavaScript_code_modules/Promise.jsm/Promise#Handling_errors_and_common_pitfalls

As of now, this amounts to a pattern like:

  myPromise.then(value => {
// ...
  }).then(null, Components.utils.reportError);

Or when creating a task without returning the promise:

  Task.spawn(function () {
// yield ...
  }).then(null, Components.utils.reportError);

I admit that having to explicitly provide an error handler at the end
of a promise chain may be considered less than optimal, but for now it
is the recommended way in new code. We're discussing ways to make it
less likely that exceptions are swallowed, in bug 902866:

https://bugzilla.mozilla.org/show_bug.cgi?id=902866

Please reply in the bug if you have anything to add to the discussion.

Cheers,
Paolo
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform