Skip to content

A platform for community discussion. Free, open, simple.

DEV: Fix set-after-destroy issues (#15078)

Jarek Radosze41f98bf96b4
diff --git a/app/assets/javascripts/admin/addon/components/dashboard-new-features.js b/app/assets/javascripts/admin/addon/components/dashboard-new-features.js
index 059e138240a..6e8defb93c4 100644
--- a/app/assets/javascripts/admin/addon/components/dashboard-new-features.js
+++ b/app/assets/javascripts/admin/addon/components/dashboard-new-features.js
@@ -12,6 +12,10 @@ export default Component.extend({
this._super(...arguments);
ajax("/admin/dashboard/new-features.json").then((json) => {
+ if (!this.element || this.isDestroying || this.isDestroyed) {
+ return;
+ }
+
this.setProperties({
newFeatures: json.new_features,
hasUnseenFeatures: json.has_unseen_features,
diff --git a/app/assets/javascripts/discourse/app/controllers/create-account.js b/app/assets/javascripts/discourse/app/controllers/create-account.js
index 946ffd0288e..370f0c210f7 100644
--- a/app/assets/javascripts/discourse/app/controllers/create-account.js
+++ b/app/assets/javascripts/discourse/app/controllers/create-account.js
@@ -211,6 +211,10 @@ export default Controller.extend(
return User.checkEmail(this.accountEmail)
.then((result) => {
+ if (this.isDestroying || this.isDestroyed) {
+ return;
+ }
+
if (result.failed) {
this.setProperties({
serverAccountEmail: this.accountEmail,
@@ -356,6 +360,10 @@ export default Controller.extend(
this.set("formSubmitted", true);
return User.createAccount(attrs).then(
(result) => {
+ if (this.isDestroying || this.isDestroyed) {
+ return;
+ }
+
this.set("isDeveloper", false);
if (result.success) {
// invalidate honeypot
diff --git a/app/assets/javascripts/discourse/app/mixins/username-validation.js b/app/assets/javascripts/discourse/app/mixins/username-validation.js
index 522b40ad5f0..2e11cb75eb5 100644
--- a/app/assets/javascripts/discourse/app/mixins/username-validation.js
+++ b/app/assets/javascripts/discourse/app/mixins/username-validation.js
@@ -86,6 +86,10 @@ export default Mixin.create({
checkUsernameAvailability() {
return User.checkUsername(this.accountUsername, this.accountEmail).then(
(result) => {
+ if (this.isDestroying || this.isDestroyed) {
+ return;
+ }
+
this.set("isDeveloper", false);
if (result.available) {
if (result.is_developer) {