-
Notifications
You must be signed in to change notification settings - Fork 55
If an error is thrown in otherwise() handler, future promises are broken #29
Comments
See #11 regarding unit tests. @karfau is porting the Promises/A+ specification test suite to: https://github.com/karfau/promises-tests-as3. We will be restructuring the repo soon to introduce FlexUnit tests for Promise-AS3 specific utility methods, etc. that would not be covered by the standard validation suite. While working on a JavaScript variation of this same code for Deft JS (where I do have extensive unit tests), I discovered this same issue. The problem relates to recent optimizations in nextTick() / CallbackQueue and their use in Promise::log() and Promise::done(). I'll port the associated fix for this back later this afternoon and will post an update here when it is available. Thanks for reporting this issue! |
When you get a chance, could you grab the latest and verify this fixes the issue in your environment, too? Thanks! |
NOTE: it was the It was also possible for |
…all future execution of scheduled callbacks. * Revised `nextTick()` to perform safer next tick scheduling - i.e. where a scheduled callback can throw an Error without affecting other scheduled calls. * Modified `log()` and `done()` to use this safer `nextTick()` implementation to rethrow errors. * Moved the optimized CallbackQueue to be an internal class used only by Consequence, where its underlying assumption (that execute() will not throw an error) is valid. * Cloned additional CallbackQueue performance optimizations from promise.coffee and Deft JS - ensuring that only a single Array instance is used, rather than allocating new Arrays (via push(), etc.) whenever new callbacks are added. Fixes CC-Archived#29 (cherry picked from commit a33c977)
Works like a charm! Thanks for the quick fix! I'm currently building from source but it would be nice to have some versioning though ;) Anyhow thanks again and great work! |
I've encountered what I'm sure is a bug regarding error handling in promises. I'm using them with robotlegs which uses a VigilenceExtension which basically throws errors whenever a logger logs an error or a warning. Whether or not that is a good thing, I've discovered that whenever an error is thrown in a promise it cripples any other promises created afterwards. Here is a test case which IMO should pass :
In order to get this to pass, I simply need to comment out the
throw new Error()
in the 1st promise'sotherwise
, but of course the purpose of the test is to be able to handle errors. Any help would be much appreciated? Are there any unit tests planned for this library?The text was updated successfully, but these errors were encountered: