Stack overflow when calling an Ember route

We’ve just setup our project on new developer’s computer, and this started happening:

DEPRECATION: When calling `Ember.deprecate` you must provide an `options` hash as the third parameter.  `options` should include `id` and `until` properties. [deprecation id: ember-debug.deprecate-options-missing] See http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options for more details.
        at logDeprecationStackTrace (http://localhost:4200/assets/vendor.js:21055:19)
        at HANDLERS.(anonymous function) (http://localhost:4200/assets/vendor.js:21166:7)
        at raiseOnDeprecation (http://localhost:4200/assets/vendor.js:21085:12)
        at HANDLERS.(anonymous function) (http://localhost:4200/assets/vendor.js:21166:7)
        at invoke (http://localhost:4200/assets/vendor.js:21182:7)
        at deprecate (http://localhost:4200/assets/vendor.js:21150:32)
        at deprecate (http://localhost:4200/assets/vendor.js:21127:7)
        at Object.deprecate (http://localhost:4200/assets/vendor.js:32913:37)
        at deprecate (http://localhost:4200/assets/vendor.js:83446:40)

This warning was raised over 3000 times!

Following this warning, we get the following:

Uncaught RangeError: Maximum call stack size exceeded
    at RegExp.[Symbol.replace] (native)
    at String.replace (native)
    at logDeprecationStackTrace (http://localhost:4200/assets/vendor.js:21065:31)
    at HANDLERS.(anonymous function) (http://localhost:4200/assets/vendor.js:21166:7)
    at raiseOnDeprecation (http://localhost:4200/assets/vendor.js:21085:12)
    at HANDLERS.(anonymous function) (http://localhost:4200/assets/vendor.js:21166:7)
    at invoke (http://localhost:4200/assets/vendor.js:21182:7)
    at deprecate (http://localhost:4200/assets/vendor.js:21150:32)
    at deprecate (http://localhost:4200/assets/vendor.js:21127:7)
    at Object.deprecate (http://localhost:4200/assets/vendor.js:32913:37)

This isn’t happening on any of the other developer’s machines who had the project setup before. We’re not quite sure where to start to debug this situation.

Here’s the code that seems to be triggering it:

import Ember from 'ember';

export default Ember.Route.extend({
  model() {
    let solution = this.store.createRecord('solution');

    return solution;
  },

  afterModel(model) {
    model.save().then(() => this.transitionTo('solution.edit.your-idea', model.id));
  }
});

It seems like it has something to do with the transitionTo call within the afterModel hook because when I comment out that line, the stack overflow does not occur.

It’s also strange that this has just started happening. It wasn’t an issue before.

At a guess I’d say that when you call transitionTo with an id, it is refetching the model for which is calling createRecord repeatedly. Try swapping model.id for model and that should stop it reloading the entire model and hence getting stuck in a loop.

Like I said, just a guess as there could be other code that is contributing to the problem.

The code you have written can definitely not be correct, neither will swapping model.id for model.

Your model has just been created. It has no id. So you can’t transition to a route with that model as one of the route models. This design cannot work correctly.

Thanks for the feedback, Alex.

I just want to bring your attention to this fragment of code: model.save().then(...)

save() returns a promise, does it not? Which then gets handled by the then() which has two callback functions – one on success and one on error.

The strange thing is that this was working up until this week. We had been running this code for almost 3 months.

Ill give this a shot, Ricky. Thanks!

please post which one worked :slight_smile: