@trigger.dev/redis-worker 4.0.0 → 4.0.2

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
@@ -11450,11 +11450,11 @@ var Worker = class _Worker {
11450
11450
  const catalogItem = this.options.catalog[job];
11451
11451
  const handler = this.jobs[job];
11452
11452
  if (!handler) {
11453
- this.logger.error(`No handler found for job type: ${job}`);
11453
+ this.logger.error(`Worker no handler found for job type: ${job}`);
11454
11454
  return;
11455
11455
  }
11456
11456
  if (!catalogItem) {
11457
- this.logger.error(`No catalog item found for job type: ${job}`);
11457
+ this.logger.error(`Worker no catalog item found for job type: ${job}`);
11458
11458
  return;
11459
11459
  }
11460
11460
  await startSpan(
@@ -11494,7 +11494,8 @@ var Worker = class _Worker {
11494
11494
  }
11495
11495
  ).catch(async (error) => {
11496
11496
  const errorMessage = error instanceof Error ? error.message : String(error);
11497
- this.logger.error(`Error processing item:`, {
11497
+ const shouldLogError = catalogItem.logErrors ?? true;
11498
+ const logAttributes = {
11498
11499
  name: this.options.name,
11499
11500
  id,
11500
11501
  job,
@@ -11502,7 +11503,12 @@ var Worker = class _Worker {
11502
11503
  visibilityTimeoutMs,
11503
11504
  error,
11504
11505
  errorMessage
11505
- });
11506
+ };
11507
+ if (shouldLogError) {
11508
+ this.logger.error(`Worker error processing item`, logAttributes);
11509
+ } else {
11510
+ this.logger.info(`Worker failed to process item`, logAttributes);
11511
+ }
11506
11512
  try {
11507
11513
  const newAttempt = attempt + 1;
11508
11514
  const retrySettings = {
@@ -11511,15 +11517,17 @@ var Worker = class _Worker {
11511
11517
  };
11512
11518
  const retryDelay = v3.calculateNextRetryDelay(retrySettings, newAttempt);
11513
11519
  if (!retryDelay) {
11514
- this.logger.error(`Item ${id} reached max attempts. Moving to DLQ.`, {
11515
- name: this.options.name,
11516
- id,
11517
- job,
11518
- item,
11519
- visibilityTimeoutMs,
11520
- attempt: newAttempt,
11521
- errorMessage
11522
- });
11520
+ if (shouldLogError) {
11521
+ this.logger.error(`Worker item reached max attempts. Moving to DLQ.`, {
11522
+ ...logAttributes,
11523
+ attempt: newAttempt
11524
+ });
11525
+ } else {
11526
+ this.logger.info(`Worker item reached max attempts. Moving to DLQ.`, {
11527
+ ...logAttributes,
11528
+ attempt: newAttempt
11529
+ });
11530
+ }
11523
11531
  await this.queue.moveToDeadLetterQueue(id, errorMessage);
11524
11532
  if (catalogItem.cron) {
11525
11533
  await this.rescheduleCronJob(job, catalogItem, item);
@@ -11527,7 +11535,7 @@ var Worker = class _Worker {
11527
11535
  return;
11528
11536
  }
11529
11537
  const retryDate = new Date(Date.now() + retryDelay);
11530
- this.logger.info(`Requeuing failed item ${id} with delay`, {
11538
+ this.logger.info(`Worker requeuing failed item with delay`, {
11531
11539
  name: this.options.name,
11532
11540
  id,
11533
11541
  job,
@@ -11547,7 +11555,7 @@ var Worker = class _Worker {
11547
11555
  });
11548
11556
  } catch (requeueError) {
11549
11557
  this.logger.error(
11550
- `Failed to requeue item ${id}. It will be retried after the visibility timeout.`,
11558
+ `Worker failed to requeue item. It will be retried after the visibility timeout.`,
11551
11559
  {
11552
11560
  name: this.options.name,
11553
11561
  id,