From 9d0e9e10ab7edc8b25ecca18d52f6c31bd141d68 Mon Sep 17 00:00:00 2001 From: Scott Kidder Date: Tue, 5 Feb 2019 22:13:16 -0500 Subject: [PATCH] fix: cancel the run.later on willDestroy to prevent async leakage as identified by qunit test isolation --- app/components/loading-slider.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/components/loading-slider.js b/app/components/loading-slider.js index ce7b66b..4944378 100644 --- a/app/components/loading-slider.js +++ b/app/components/loading-slider.js @@ -45,6 +45,7 @@ export default Component.extend({ this.get('loadingSlider').off('startLoading', this, this._startLoading); this.get('loadingSlider').off('endLoading', this, this._endLoading); this.get('loadingSlider').off('changeAttrs', this, this._changeAttrs); + run.cancel(this.get('_clearLater')); }); }, @@ -109,10 +110,12 @@ export default Component.extend({ } if (innerWidth > outerWidth) { - run.later(function() { - outer.empty(); - window.clearInterval(interval); - }, 50); + if (!self.get('isDestroyed') && !self.get('isDestroying')) { + self.set('_clearLater', run.later(function() { + outer.empty(); + window.clearInterval(interval); + }, 50)); + } } // the activity has finished