Unresolved Promises

I have a model with belongsto relationships. When the related records cannot be found, an exception is thrown. This is ok, but the default promise error handling code prevents the run-loop from from flushing the remaining tasks. It just drops everything and dies, leaving all those unresolved promises in limbo.

The code in question:

RSVP.onerrorDefault = function(error) {
      if (error instanceof Error) {
        if (Ember.testing) {
          // ES6TODO: remove when possible
          if (!Test && Ember.__loader.registry[testModuleName]) {
            Test = requireModule(testModuleName)['default'];
          }

          if (Test && Test.adapter) {
            Test.adapter.exception(error);
          } else {
            throw error;
          }
        } else if (Ember.onerror) {
          Ember.onerror(error);
        } else {
          Logger.error(error.stack);
          Ember.assert(error, false);
        }
      }
    };

If no Ember error handler is defined, or the default promise error handler is not changed, this code will throw an exception. That exception then kills the run loop and permanently suspends any promise chains still in queue.

Its a problem, but at least I discovered how to deal with it, by making an error handler… (Ember.K works until I get inspired).

“Ember.K works”… what exactly does this mean? I have an RSVP.hash($.getJSON()) that blows up on error.stack even though I am using an actions:{error:function(){}} handler.

@nathanseeley I believe just defining an Ember.onerror function is an effective work around for this issue. Additionally this problem should be fixed in Ember 1.10 thanks to this pr from @matchy [BUGFIX beta] Don’t assert uncaught RSVP rejections by machty · Pull Request #9904 · emberjs/ember.js · GitHub