mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Fixed TaskCancelation errors
sentry issue: ADMIN-AY5 - added guards for cancelation errors where we're casting tasks to promises - see http://ember-concurrency.com/docs/task-cancelation-help for full details
This commit is contained in:
parent
8d9d22e5a7
commit
d15f740a3f
5 changed files with 50 additions and 16 deletions
|
@ -1,7 +1,7 @@
|
|||
import Component from '@glimmer/component';
|
||||
import {action} from '@ember/object';
|
||||
import {didCancel, task} from 'ember-concurrency';
|
||||
import {inject as service} from '@ember/service';
|
||||
import {task} from 'ember-concurrency';
|
||||
import {tracked} from '@glimmer/tracking';
|
||||
|
||||
/**
|
||||
|
@ -187,10 +187,17 @@ export default class Analytics extends Component {
|
|||
}
|
||||
|
||||
async fetchReferrersStats() {
|
||||
if (this._fetchReferrersStats.isRunning) {
|
||||
return this._fetchReferrersStats.last;
|
||||
try {
|
||||
if (this._fetchReferrersStats.isRunning) {
|
||||
return this._fetchReferrersStats.last;
|
||||
}
|
||||
return this._fetchReferrersStats.perform();
|
||||
} catch (e) {
|
||||
if (!didCancel(e)) {
|
||||
// re-throw the non-cancelation error
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
return this._fetchReferrersStats.perform();
|
||||
}
|
||||
|
||||
async fetchLinks() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import Component from '@glimmer/component';
|
||||
import {action} from '@ember/object';
|
||||
import {didCancel, task} from 'ember-concurrency';
|
||||
import {inject as service} from '@ember/service';
|
||||
import {task} from 'ember-concurrency';
|
||||
import {tracked} from '@glimmer/tracking';
|
||||
|
||||
/**
|
||||
|
@ -165,10 +165,17 @@ export default class Analytics extends Component {
|
|||
}
|
||||
|
||||
async fetchReferrersStats() {
|
||||
if (this._fetchReferrersStats.isRunning) {
|
||||
return this._fetchReferrersStats.last;
|
||||
try {
|
||||
if (this._fetchReferrersStats.isRunning) {
|
||||
return this._fetchReferrersStats.last;
|
||||
}
|
||||
return this._fetchReferrersStats.perform();
|
||||
} catch (e) {
|
||||
if (!didCancel(e)) {
|
||||
// re-throw the non-cancelation error
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
return this._fetchReferrersStats.perform();
|
||||
}
|
||||
|
||||
async fetchLinks() {
|
||||
|
|
|
@ -2,8 +2,8 @@ import moment from 'moment-timezone';
|
|||
import {Resource} from 'ember-could-get-used-to-this';
|
||||
import {TrackedArray} from 'tracked-built-ins';
|
||||
import {action} from '@ember/object';
|
||||
import {didCancel, task} from 'ember-concurrency';
|
||||
import {inject as service} from '@ember/service';
|
||||
import {task} from 'ember-concurrency';
|
||||
import {tracked} from '@glimmer/tracking';
|
||||
|
||||
const actions = {
|
||||
|
@ -59,7 +59,14 @@ export default class ActivityFeedFetcher extends Resource {
|
|||
filter += `+${this.args.named.filter}`;
|
||||
}
|
||||
|
||||
await this.loadEventsTask.perform({filter}, actions.showNext);
|
||||
try {
|
||||
await this.loadEventsTask.perform({filter}, actions.showNext);
|
||||
} catch (e) {
|
||||
if (!didCancel(e)) {
|
||||
// re-throw the non-cancelation error
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
|
|
|
@ -2,8 +2,8 @@ import moment from 'moment-timezone';
|
|||
import {Resource} from 'ember-could-get-used-to-this';
|
||||
import {TrackedArray} from 'tracked-built-ins';
|
||||
import {action} from '@ember/object';
|
||||
import {didCancel, task} from 'ember-concurrency';
|
||||
import {inject as service} from '@ember/service';
|
||||
import {task} from 'ember-concurrency';
|
||||
import {tracked} from '@glimmer/tracking';
|
||||
|
||||
export default class HistoryEventFetcher extends Resource {
|
||||
|
@ -38,8 +38,14 @@ export default class HistoryEventFetcher extends Resource {
|
|||
filter += `+${this.args.named.filter}`;
|
||||
}
|
||||
|
||||
// Can't get this working with Promise.all, somehow results in an infinite loop
|
||||
await this.loadEventsTask.perform({filter});
|
||||
try {
|
||||
await this.loadEventsTask.perform({filter});
|
||||
} catch (e) {
|
||||
if (!didCancel(e)) {
|
||||
// re-throw the non-cancelation error
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
|
|
|
@ -2,8 +2,8 @@ import moment from 'moment-timezone';
|
|||
import {Resource} from 'ember-could-get-used-to-this';
|
||||
import {TrackedArray} from 'tracked-built-ins';
|
||||
import {action} from '@ember/object';
|
||||
import {didCancel, task} from 'ember-concurrency';
|
||||
import {inject as service} from '@ember/service';
|
||||
import {task} from 'ember-concurrency';
|
||||
import {tracked} from '@glimmer/tracking';
|
||||
|
||||
export default class MembersEventsFetcher extends Resource {
|
||||
|
@ -46,8 +46,15 @@ export default class MembersEventsFetcher extends Resource {
|
|||
}
|
||||
|
||||
// Can't get this working with Promise.all, somehow results in an infinite loop
|
||||
await this.loadEventsTask.perform({filter});
|
||||
await this.loadMultipleNewslettersTask.perform();
|
||||
try {
|
||||
await this.loadEventsTask.perform({filter});
|
||||
await this.loadMultipleNewslettersTask.perform();
|
||||
} catch (e) {
|
||||
if (!didCancel(e)) {
|
||||
// re-throw the non-cancelation error
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
|
|
Loading…
Add table
Reference in a new issue