@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.d.cts CHANGED
@@ -104,6 +104,8 @@ type WorkerCatalog = {
104
104
  retry?: RetryOptions;
105
105
  cron?: string;
106
106
  jitterInMs?: number;
107
+ /** Defaults to true. If false, errors will not be logged. */
108
+ logErrors?: boolean;
107
109
  };
108
110
  };
109
111
  type QueueCatalogFromWorkerCatalog<Catalog extends WorkerCatalog> = {
package/dist/index.d.ts CHANGED
@@ -104,6 +104,8 @@ type WorkerCatalog = {
104
104
  retry?: RetryOptions;
105
105
  cron?: string;
106
106
  jitterInMs?: number;
107
+ /** Defaults to true. If false, errors will not be logged. */
108
+ logErrors?: boolean;
107
109
  };
108
110
  };
109
111
  type QueueCatalogFromWorkerCatalog<Catalog extends WorkerCatalog> = {
package/dist/index.js CHANGED
@@ -11444,11 +11444,11 @@ var Worker = class _Worker {
11444
11444
  const catalogItem = this.options.catalog[job];
11445
11445
  const handler = this.jobs[job];
11446
11446
  if (!handler) {
11447
- this.logger.error(`No handler found for job type: ${job}`);
11447
+ this.logger.error(`Worker no handler found for job type: ${job}`);
11448
11448
  return;
11449
11449
  }
11450
11450
  if (!catalogItem) {
11451
- this.logger.error(`No catalog item found for job type: ${job}`);
11451
+ this.logger.error(`Worker no catalog item found for job type: ${job}`);
11452
11452
  return;
11453
11453
  }
11454
11454
  await startSpan(
@@ -11488,7 +11488,8 @@ var Worker = class _Worker {
11488
11488
  }
11489
11489
  ).catch(async (error) => {
11490
11490
  const errorMessage = error instanceof Error ? error.message : String(error);
11491
- this.logger.error(`Error processing item:`, {
11491
+ const shouldLogError = catalogItem.logErrors ?? true;
11492
+ const logAttributes = {
11492
11493
  name: this.options.name,
11493
11494
  id,
11494
11495
  job,
@@ -11496,7 +11497,12 @@ var Worker = class _Worker {
11496
11497
  visibilityTimeoutMs,
11497
11498
  error,
11498
11499
  errorMessage
11499
- });
11500
+ };
11501
+ if (shouldLogError) {
11502
+ this.logger.error(`Worker error processing item`, logAttributes);
11503
+ } else {
11504
+ this.logger.info(`Worker failed to process item`, logAttributes);
11505
+ }
11500
11506
  try {
11501
11507
  const newAttempt = attempt + 1;
11502
11508
  const retrySettings = {
@@ -11505,15 +11511,17 @@ var Worker = class _Worker {
11505
11511
  };
11506
11512
  const retryDelay = calculateNextRetryDelay(retrySettings, newAttempt);
11507
11513
  if (!retryDelay) {
11508
- this.logger.error(`Item ${id} reached max attempts. Moving to DLQ.`, {
11509
- name: this.options.name,
11510
- id,
11511
- job,
11512
- item,
11513
- visibilityTimeoutMs,
11514
- attempt: newAttempt,
11515
- errorMessage
11516
- });
11514
+ if (shouldLogError) {
11515
+ this.logger.error(`Worker item reached max attempts. Moving to DLQ.`, {
11516
+ ...logAttributes,
11517
+ attempt: newAttempt
11518
+ });
11519
+ } else {
11520
+ this.logger.info(`Worker item reached max attempts. Moving to DLQ.`, {
11521
+ ...logAttributes,
11522
+ attempt: newAttempt
11523
+ });
11524
+ }
11517
11525
  await this.queue.moveToDeadLetterQueue(id, errorMessage);
11518
11526
  if (catalogItem.cron) {
11519
11527
  await this.rescheduleCronJob(job, catalogItem, item);
@@ -11521,7 +11529,7 @@ var Worker = class _Worker {
11521
11529
  return;
11522
11530
  }
11523
11531
  const retryDate = new Date(Date.now() + retryDelay);
11524
- this.logger.info(`Requeuing failed item ${id} with delay`, {
11532
+ this.logger.info(`Worker requeuing failed item with delay`, {
11525
11533
  name: this.options.name,
11526
11534
  id,
11527
11535
  job,
@@ -11541,7 +11549,7 @@ var Worker = class _Worker {
11541
11549
  });
11542
11550
  } catch (requeueError) {
11543
11551
  this.logger.error(
11544
- `Failed to requeue item ${id}. It will be retried after the visibility timeout.`,
11552
+ `Worker failed to requeue item. It will be retried after the visibility timeout.`,
11545
11553
  {
11546
11554
  name: this.options.name,
11547
11555
  id,