@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.js CHANGED
@@ -11593,22 +11593,22 @@ var Worker = class _Worker {
11593
11593
  ).catch(async (error) => {
11594
11594
  const errorMessage = error instanceof Error ? error.message : String(error);
11595
11595
  const shouldLogError = catalogItem.logErrors ?? true;
11596
- if (shouldLogError) {
11597
- this.logger.error(`Worker error processing batch`, {
11598
- name: this.options.name,
11599
- jobType,
11600
- batchSize: items.length,
11601
- error,
11602
- errorMessage
11603
- });
11596
+ const errorLogLevel = error && typeof error === "object" && "logLevel" in error ? error.logLevel : void 0;
11597
+ const logAttributes = {
11598
+ name: this.options.name,
11599
+ jobType,
11600
+ batchSize: items.length,
11601
+ error,
11602
+ errorMessage
11603
+ };
11604
+ if (!shouldLogError) {
11605
+ this.logger.info(`Worker failed to process batch`, logAttributes);
11606
+ } else if (errorLogLevel === "warn") {
11607
+ this.logger.warn(`Worker error processing batch`, logAttributes);
11608
+ } else if (errorLogLevel === "info") {
11609
+ this.logger.info(`Worker error processing batch`, logAttributes);
11604
11610
  } else {
11605
- this.logger.info(`Worker failed to process batch`, {
11606
- name: this.options.name,
11607
- jobType,
11608
- batchSize: items.length,
11609
- error,
11610
- errorMessage
11611
- });
11611
+ this.logger.error(`Worker error processing batch`, logAttributes);
11612
11612
  }
11613
11613
  for (const item of items) {
11614
11614
  try {
@@ -11619,20 +11619,20 @@ var Worker = class _Worker {
11619
11619
  };
11620
11620
  const retryDelay = calculateNextRetryDelay(retrySettings, newAttempt);
11621
11621
  if (!retryDelay) {
11622
- if (shouldLogError) {
11623
- this.logger.error(`Worker batch item reached max attempts. Moving to DLQ.`, {
11624
- name: this.options.name,
11625
- id: item.id,
11626
- jobType,
11627
- attempt: newAttempt
11628
- });
11622
+ const dlqLogAttributes = {
11623
+ name: this.options.name,
11624
+ id: item.id,
11625
+ jobType,
11626
+ attempt: newAttempt
11627
+ };
11628
+ if (!shouldLogError) {
11629
+ this.logger.info(`Worker batch item reached max attempts. Moving to DLQ.`, dlqLogAttributes);
11630
+ } else if (errorLogLevel === "warn") {
11631
+ this.logger.warn(`Worker batch item reached max attempts. Moving to DLQ.`, dlqLogAttributes);
11632
+ } else if (errorLogLevel === "info") {
11633
+ this.logger.info(`Worker batch item reached max attempts. Moving to DLQ.`, dlqLogAttributes);
11629
11634
  } else {
11630
- this.logger.info(`Worker batch item reached max attempts. Moving to DLQ.`, {
11631
- name: this.options.name,
11632
- id: item.id,
11633
- jobType,
11634
- attempt: newAttempt
11635
- });
11635
+ this.logger.error(`Worker batch item reached max attempts. Moving to DLQ.`, dlqLogAttributes);
11636
11636
  }
11637
11637
  await this.queue.moveToDeadLetterQueue(item.id, errorMessage);
11638
11638
  continue;
@@ -11721,6 +11721,7 @@ var Worker = class _Worker {
11721
11721
  ).catch(async (error) => {
11722
11722
  const errorMessage = error instanceof Error ? error.message : String(error);
11723
11723
  const shouldLogError = catalogItem.logErrors ?? true;
11724
+ const errorLogLevel = error && typeof error === "object" && "logLevel" in error ? error.logLevel : void 0;
11724
11725
  const logAttributes = {
11725
11726
  name: this.options.name,
11726
11727
  id,
@@ -11730,10 +11731,14 @@ var Worker = class _Worker {
11730
11731
  error,
11731
11732
  errorMessage
11732
11733
  };
11733
- if (shouldLogError) {
11734
- this.logger.error(`Worker error processing item`, logAttributes);
11735
- } else {
11734
+ if (!shouldLogError) {
11736
11735
  this.logger.info(`Worker failed to process item`, logAttributes);
11736
+ } else if (errorLogLevel === "warn") {
11737
+ this.logger.warn(`Worker error processing item`, logAttributes);
11738
+ } else if (errorLogLevel === "info") {
11739
+ this.logger.info(`Worker error processing item`, logAttributes);
11740
+ } else {
11741
+ this.logger.error(`Worker error processing item`, logAttributes);
11737
11742
  }
11738
11743
  try {
11739
11744
  const newAttempt = attempt + 1;
@@ -11743,13 +11748,18 @@ var Worker = class _Worker {
11743
11748
  };
11744
11749
  const retryDelay = calculateNextRetryDelay(retrySettings, newAttempt);
11745
11750
  if (!retryDelay) {
11746
- if (shouldLogError) {
11747
- this.logger.error(`Worker item reached max attempts. Moving to DLQ.`, {
11751
+ if (!shouldLogError || errorLogLevel === "info") {
11752
+ this.logger.info(`Worker item reached max attempts. Moving to DLQ.`, {
11753
+ ...logAttributes,
11754
+ attempt: newAttempt
11755
+ });
11756
+ } else if (errorLogLevel === "warn") {
11757
+ this.logger.warn(`Worker item reached max attempts. Moving to DLQ.`, {
11748
11758
  ...logAttributes,
11749
11759
  attempt: newAttempt
11750
11760
  });
11751
11761
  } else {
11752
- this.logger.info(`Worker item reached max attempts. Moving to DLQ.`, {
11762
+ this.logger.error(`Worker item reached max attempts. Moving to DLQ.`, {
11753
11763
  ...logAttributes,
11754
11764
  attempt: newAttempt
11755
11765
  });
@@ -11828,7 +11838,7 @@ var Worker = class _Worker {
11828
11838
  Promise.allSettled(enqueuePromises).then((results) => {
11829
11839
  results.forEach((result) => {
11830
11840
  if (result.status === "fulfilled") {
11831
- this.logger.info("Enqueued cron job", { result: result.value });
11841
+ this.logger.debug("Enqueued cron job", { result: result.value });
11832
11842
  } else {
11833
11843
  this.logger.error("Failed to enqueue cron job", { reason: result.reason });
11834
11844
  }
@@ -11850,7 +11860,7 @@ var Worker = class _Worker {
11850
11860
  },
11851
11861
  availableAt
11852
11862
  });
11853
- this.logger.info("Enqueued cron job", {
11863
+ this.logger.debug("Enqueued cron job", {
11854
11864
  identifier,
11855
11865
  cron,
11856
11866
  job,