Uncaught Error: Assertion Failed: calling set on destroyed object

后端 未结 4 1166
旧巷少年郎
旧巷少年郎 2021-02-05 00:09

working in ember-cli testing. After all tests passed it returns extra two test with errors.

Uncaught Error: Assertion Failed: calling set on destroyed obj

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-05 00:45

    Ok i struggled with similar thing. So basically when you have "this.set()" inside a promise, it might happen that the promise takes too long to resolve, and the user already clicked away from that page, in this case you are trying to set something, that is already destroyed. I found the simplest solution to be just a simple check in the beginning of the promise.

    if (this.isDestroyed) {
        return;
    }
    this.set('...');
    ...
    

    Edit: alternatively you can use Ember.trySet.

提交回复
热议问题