diff --git a/apps/meteor/app/apps/server/bridges/scheduler.ts b/apps/meteor/app/apps/server/bridges/scheduler.ts index c64ffd1d9f874..358e350f9280e 100644 --- a/apps/meteor/app/apps/server/bridges/scheduler.ts +++ b/apps/meteor/app/apps/server/bridges/scheduler.ts @@ -226,18 +226,22 @@ export class AppSchedulerBridge extends SchedulerBridge { * * @returns Promise */ - protected async cancelJobByDataQuery(data: object, appId: string): Promise { - const dataQuery = this.getQueryFromObject('data', data); - this.orch.debugLog(`Canceling all jobs of App ${appId} matching ${JSON.stringify(dataQuery)}`); - await this.startScheduler(); - const matcher = new RegExp(`_${appId}$`); - try { - await this.scheduler.cancel({ name: { $regex: matcher }, ...dataQuery }); - this.orch.debugLog(`Cancelled all jobs of App ${appId} matching ${JSON.stringify(dataQuery)}`); - } catch (e) { - this.orch.debugLog(`Error in Canceling all jobs of App ${appId} matching ${JSON.stringify(dataQuery)}`); - console.error(e); - } + protected cancelJobByDataQuery(data: object, appId: string): Promise { + return new Promise(async (resolve, reject) => { + const dataQuery = this.getQueryFromObject('data', data); + this.orch.debugLog(`Canceling all jobs of App ${appId} matching ${JSON.stringify(dataQuery)}`); + const matcher = new RegExp(`_${appId}$`); + try { + await this.startScheduler(); + const cancel = await this.scheduler.cancel({ name: { $regex: matcher }, ...dataQuery }); + this.orch.debugLog(`Cancelled all jobs of App ${appId} matching ${JSON.stringify(dataQuery)}`); + resolve(cancel); + } catch (e) { + this.orch.debugLog(`Error in Canceling all jobs of App ${appId} matching ${JSON.stringify(dataQuery)}`); + console.error(e); + reject(e); + } + }); } public async startScheduler(): Promise {