Browse Source

fix(core): Handle search job buffer timeout errors, increase timeout

Relates to #1287
Michael Bromley 4 years ago
parent
commit
8797456adf

+ 1 - 1
packages/core/src/job-queue/subscribable-job.ts

@@ -69,7 +69,7 @@ export class SubscribableJob<T extends JobData<T> = any> extends Job<T> {
                 tap(i => {
                     if (timeoutMs < i * pollInterval) {
                         throw new Error(
-                            `Job ${this.id} update polling timed out after ${timeoutMs}ms. The job may still be running.`,
+                            `Job ${this.id} SubscribableJob update polling timed out after ${timeoutMs}ms. The job may still be running.`,
                         );
                     }
                 }),

+ 7 - 2
packages/core/src/plugin/default-search-plugin/search-job-buffer/search-job-buffer.service.ts

@@ -3,6 +3,7 @@ import { forkJoin } from 'rxjs';
 
 import { ConfigService } from '../../../config/config.service';
 import { isInspectableJobQueueStrategy } from '../../../config/job-queue/inspectable-job-queue-strategy';
+import { Logger } from '../../../config/logger/vendure-logger';
 import { JobQueueService } from '../../../job-queue/job-queue.service';
 import { SubscribableJob } from '../../../job-queue/subscribable-job';
 import { BUFFER_SEARCH_INDEX_UPDATES } from '../constants';
@@ -54,9 +55,13 @@ export class SearchJobBufferService implements OnApplicationBootstrap {
             );
             await forkJoin(
                 ...subscribableCollectionJobs.map(sj =>
-                    sj.updates({ pollInterval: 500, timeoutMs: 3 * 60 * 1000 }),
+                    sj.updates({ pollInterval: 500, timeoutMs: 15 * 60 * 1000 }),
                 ),
-            ).toPromise();
+            )
+                .toPromise()
+                .catch(err => {
+                    Logger.error(err.message);
+                });
         }
         await this.jobQueueService.flush(this.searchIndexJobBuffer);
     }