Nayigiziki / closure-library

Automatically exported from code.google.com/p/closure-library
0 stars 0 forks source link

goog.async.Deferred sometimes does not throw unhandled errors #632

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago

What steps will reproduce the problem?
1. Run the unit tests in the attached file, containing four new tests that I 
added: testBlockingDeferredThrowsError1, testBlockingDeferredThrowsError2, 
testAwaitDeferredThrowsError1 and testAwaitDeferredThrowsError2
2. All new tests will fail

What is the expected output? What do you see instead?

All tests should pass.

What version of the product are you using? On what operating system?

e76158563f30aa17760e9c887be2ea66b29cfe31

Please provide any additional information below.

As far as I understand, any error thrown inside Deferred callback should escape 
its scope, provided that the Deferred doesn't have any errbacks that will 
handle that error and return a non-error value. IOW the Deferred object should 
rethrow the error so that it can be handled outside of its scope.

This works as expected for other situations, like when using chainDeferred(). 
This is (presumably) the correct behavior can be observed in 
testChainedDeferred2.

However when using blocking Deferred objects (i.e. the ones registered with 
awaitDeferred() or returned in a callback) that throw errors, the out Deferred 
object remains silent, no errors are thrown.

As far as I can see, the very same behavior that applies to chainDeferred() 
with regards to throwing exceptions should apply for blocking Deferred objects 
so that errors can propagate as expected.

Original issue reported on code.google.com by alo.and on 21 Mar 2014 at 4:37

Attachments:

GoogleCodeExporter commented 8 years ago
goog.async.Deferred will soon be phased out in favor of goog.Promise.

Original comment by pall...@google.com on 2 Apr 2014 at 8:32

GoogleCodeExporter commented 8 years ago
goog.Promise is also not throwing unhandled errors. It should, as goog.Promise 
calls goog.async.throwException by default on unhandled rejected promises.

Please check Issue 640.

Original comment by alo.and on 21 Apr 2014 at 10:02