Browse Source

fix(core): Correctly calculate job duration for pending/retrying jobs

Michael Bromley 4 years ago
parent
commit
73fa2781f5
1 changed files with 3 additions and 0 deletions
  1. 3 0
      packages/core/src/job-queue/job.ts

+ 3 - 0
packages/core/src/job-queue/job.ts

@@ -93,6 +93,9 @@ export class Job<T extends JobData<T> = any> {
     }
 
     get duration(): number {
+        if (this.state === JobState.PENDING || this.state === JobState.RETRYING) {
+            return 0;
+        }
         const end = this._settledAt || new Date();
         return +end - +(this._startedAt || end);
     }