@trigger.dev/redis-worker 4.4.2 → 4.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -11600,22 +11600,22 @@ var Worker = class _Worker {
11600
11600
  ).catch(async (error) => {
11601
11601
  const errorMessage = error instanceof Error ? error.message : String(error);
11602
11602
  const shouldLogError = catalogItem.logErrors ?? true;
11603
- if (shouldLogError) {
11604
- this.logger.error(`Worker error processing batch`, {
11605
- name: this.options.name,
11606
- jobType,
11607
- batchSize: items.length,
11608
- error,
11609
- errorMessage
11610
- });
11603
+ const errorLogLevel = error && typeof error === "object" && "logLevel" in error ? error.logLevel : void 0;
11604
+ const logAttributes = {
11605
+ name: this.options.name,
11606
+ jobType,
11607
+ batchSize: items.length,
11608
+ error,
11609
+ errorMessage
11610
+ };
11611
+ if (!shouldLogError) {
11612
+ this.logger.info(`Worker failed to process batch`, logAttributes);
11613
+ } else if (errorLogLevel === "warn") {
11614
+ this.logger.warn(`Worker error processing batch`, logAttributes);
11615
+ } else if (errorLogLevel === "info") {
11616
+ this.logger.info(`Worker error processing batch`, logAttributes);
11611
11617
  } else {
11612
- this.logger.info(`Worker failed to process batch`, {
11613
- name: this.options.name,
11614
- jobType,
11615
- batchSize: items.length,
11616
- error,
11617
- errorMessage
11618
- });
11618
+ this.logger.error(`Worker error processing batch`, logAttributes);
11619
11619
  }
11620
11620
  for (const item of items) {
11621
11621
  try {
@@ -11626,20 +11626,20 @@ var Worker = class _Worker {
11626
11626
  };
11627
11627
  const retryDelay = v3.calculateNextRetryDelay(retrySettings, newAttempt);
11628
11628
  if (!retryDelay) {
11629
- if (shouldLogError) {
11630
- this.logger.error(`Worker batch item reached max attempts. Moving to DLQ.`, {
11631
- name: this.options.name,
11632
- id: item.id,
11633
- jobType,
11634
- attempt: newAttempt
11635
- });
11629
+ const dlqLogAttributes = {
11630
+ name: this.options.name,
11631
+ id: item.id,
11632
+ jobType,
11633
+ attempt: newAttempt
11634
+ };
11635
+ if (!shouldLogError) {
11636
+ this.logger.info(`Worker batch item reached max attempts. Moving to DLQ.`, dlqLogAttributes);
11637
+ } else if (errorLogLevel === "warn") {
11638
+ this.logger.warn(`Worker batch item reached max attempts. Moving to DLQ.`, dlqLogAttributes);
11639
+ } else if (errorLogLevel === "info") {
11640
+ this.logger.info(`Worker batch item reached max attempts. Moving to DLQ.`, dlqLogAttributes);
11636
11641
  } else {
11637
- this.logger.info(`Worker batch item reached max attempts. Moving to DLQ.`, {
11638
- name: this.options.name,
11639
- id: item.id,
11640
- jobType,
11641
- attempt: newAttempt
11642
- });
11642
+ this.logger.error(`Worker batch item reached max attempts. Moving to DLQ.`, dlqLogAttributes);
11643
11643
  }
11644
11644
  await this.queue.moveToDeadLetterQueue(item.id, errorMessage);
11645
11645
  continue;
@@ -11728,6 +11728,7 @@ var Worker = class _Worker {
11728
11728
  ).catch(async (error) => {
11729
11729
  const errorMessage = error instanceof Error ? error.message : String(error);
11730
11730
  const shouldLogError = catalogItem.logErrors ?? true;
11731
+ const errorLogLevel = error && typeof error === "object" && "logLevel" in error ? error.logLevel : void 0;
11731
11732
  const logAttributes = {
11732
11733
  name: this.options.name,
11733
11734
  id,
@@ -11737,10 +11738,14 @@ var Worker = class _Worker {
11737
11738
  error,
11738
11739
  errorMessage
11739
11740
  };
11740
- if (shouldLogError) {
11741
- this.logger.error(`Worker error processing item`, logAttributes);
11742
- } else {
11741
+ if (!shouldLogError) {
11743
11742
  this.logger.info(`Worker failed to process item`, logAttributes);
11743
+ } else if (errorLogLevel === "warn") {
11744
+ this.logger.warn(`Worker error processing item`, logAttributes);
11745
+ } else if (errorLogLevel === "info") {
11746
+ this.logger.info(`Worker error processing item`, logAttributes);
11747
+ } else {
11748
+ this.logger.error(`Worker error processing item`, logAttributes);
11744
11749
  }
11745
11750
  try {
11746
11751
  const newAttempt = attempt + 1;
@@ -11750,13 +11755,18 @@ var Worker = class _Worker {
11750
11755
  };
11751
11756
  const retryDelay = v3.calculateNextRetryDelay(retrySettings, newAttempt);
11752
11757
  if (!retryDelay) {
11753
- if (shouldLogError) {
11754
- this.logger.error(`Worker item reached max attempts. Moving to DLQ.`, {
11758
+ if (!shouldLogError || errorLogLevel === "info") {
11759
+ this.logger.info(`Worker item reached max attempts. Moving to DLQ.`, {
11760
+ ...logAttributes,
11761
+ attempt: newAttempt
11762
+ });
11763
+ } else if (errorLogLevel === "warn") {
11764
+ this.logger.warn(`Worker item reached max attempts. Moving to DLQ.`, {
11755
11765
  ...logAttributes,
11756
11766
  attempt: newAttempt
11757
11767
  });
11758
11768
  } else {
11759
- this.logger.info(`Worker item reached max attempts. Moving to DLQ.`, {
11769
+ this.logger.error(`Worker item reached max attempts. Moving to DLQ.`, {
11760
11770
  ...logAttributes,
11761
11771
  attempt: newAttempt
11762
11772
  });
@@ -11835,7 +11845,7 @@ var Worker = class _Worker {
11835
11845
  Promise.allSettled(enqueuePromises).then((results) => {
11836
11846
  results.forEach((result) => {
11837
11847
  if (result.status === "fulfilled") {
11838
- this.logger.info("Enqueued cron job", { result: result.value });
11848
+ this.logger.debug("Enqueued cron job", { result: result.value });
11839
11849
  } else {
11840
11850
  this.logger.error("Failed to enqueue cron job", { reason: result.reason });
11841
11851
  }
@@ -11857,7 +11867,7 @@ var Worker = class _Worker {
11857
11867
  },
11858
11868
  availableAt
11859
11869
  });
11860
- this.logger.info("Enqueued cron job", {
11870
+ this.logger.debug("Enqueued cron job", {
11861
11871
  identifier,
11862
11872
  cron,
11863
11873
  job,