Просмотр исходного кода

fix(job-queue-plugin): Do not throw on unknown job state

This can lead to worker crashes. Instead, we log an error.
Michael Bromley 6 месяцев назад
Родитель
Сommit
bb91f261a5
1 измененных файлов с 8 добавлено и 2 удалено
  1. 8 2
      packages/job-queue-plugin/src/bullmq/bullmq-job-queue-strategy.ts

+ 8 - 2
packages/job-queue-plugin/src/bullmq/bullmq-job-queue-strategy.ts

@@ -408,8 +408,14 @@ export class BullMQJobQueueStrategy implements InspectableJobQueueStrategy {
                 return isCancelled ? JobState.CANCELLED : JobState.RUNNING;
             }
             case 'unknown':
-            default:
-                throw new InternalServerError(`Could not determine job state: ${state}`);
+            default: {
+                Logger.error(
+                    `Could not determine job state for job ${jobId ?? '(unknown ID)'}: ${state}`,
+                    loggerCtx,
+                );
+                // We need to return a valid state, so we default to FAILED.
+                return JobState.FAILED;
+            }
         }
     }