From 3e57c95a2967c0a9bc6c7ef8ca7e4b967aefab32 Mon Sep 17 00:00:00 2001 From: Maximiliano Salvatti <40447063+msalvatti@users.noreply.github.com> Date: Thu, 9 Jul 2026 18:15:21 -0300 Subject: [PATCH] fix(di): decorate injectable constructor params with explicit @Inject MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The package ships a tsup/esbuild bundle, and esbuild does not emit `emitDecoratorMetadata` (design:paramtypes). Providers whose constructor params were resolved purely by reflected type metadata (QueueService, WorkerRegistry, QueueEventsRegistry, ProcessorDiscoveryService, QueueLifecycle) therefore could not be instantiated by a consumer's Nest DI container from the built dist ("Nest can't resolve dependencies ... argument at index [0]"). Decorate every such parameter with an explicit @Inject(Token). This makes DI independent of reflected metadata (aligning with the explicit-DI standard and matching @bymax-one/nest-cache), so the module boots from the bundled dist. Factory-provided services (FlowService, MetricsService, ConnectionResolver) are unaffected — their args are supplied by their useFactory inject arrays. --- src/server/lifecycle/queue-lifecycle.service.ts | 10 +++++----- src/server/services/processor-discovery.service.ts | 8 ++++---- src/server/services/queue-events-registry.service.ts | 4 ++-- src/server/services/queue.service.ts | 2 +- src/server/services/worker-registry.service.ts | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/server/lifecycle/queue-lifecycle.service.ts b/src/server/lifecycle/queue-lifecycle.service.ts index 8bd49d1..fe2c44d 100644 --- a/src/server/lifecycle/queue-lifecycle.service.ts +++ b/src/server/lifecycle/queue-lifecycle.service.ts @@ -40,11 +40,11 @@ export class QueueLifecycle implements OnModuleDestroy { private readonly logger = new Logger(QueueLifecycle.name) constructor( - private readonly workers: WorkerRegistry, - private readonly events: QueueEventsRegistry, - private readonly queues: QueueService, - private readonly flow: FlowService, - private readonly connection: ConnectionResolver, + @Inject(WorkerRegistry) private readonly workers: WorkerRegistry, + @Inject(QueueEventsRegistry) private readonly events: QueueEventsRegistry, + @Inject(QueueService) private readonly queues: QueueService, + @Inject(FlowService) private readonly flow: FlowService, + @Inject(ConnectionResolver) private readonly connection: ConnectionResolver, @Inject(BYMAX_QUEUE_RESOLVED_OPTIONS) private readonly resolved: ResolvedQueueOptions, ) {} diff --git a/src/server/services/processor-discovery.service.ts b/src/server/services/processor-discovery.service.ts index 86f1ad0..c6c0fec 100644 --- a/src/server/services/processor-discovery.service.ts +++ b/src/server/services/processor-discovery.service.ts @@ -8,7 +8,7 @@ * @layer server/services */ -import { Injectable, Logger, type OnModuleInit } from '@nestjs/common' +import { Inject, Injectable, Logger, type OnModuleInit } from '@nestjs/common' import { DiscoveryService } from '@nestjs/core' import type { Job } from 'bullmq' import { WorkerRegistry } from './worker-registry.service' @@ -61,9 +61,9 @@ export class ProcessorDiscoveryService implements OnModuleInit { private readonly registeredQueues = new Set() constructor( - private readonly discovery: DiscoveryService, - private readonly workers: WorkerRegistry, - private readonly events: QueueEventsRegistry, + @Inject(DiscoveryService) private readonly discovery: DiscoveryService, + @Inject(WorkerRegistry) private readonly workers: WorkerRegistry, + @Inject(QueueEventsRegistry) private readonly events: QueueEventsRegistry, ) {} /** diff --git a/src/server/services/queue-events-registry.service.ts b/src/server/services/queue-events-registry.service.ts index f35c494..e0cd0a6 100644 --- a/src/server/services/queue-events-registry.service.ts +++ b/src/server/services/queue-events-registry.service.ts @@ -7,7 +7,7 @@ * @layer server/services */ -import { Injectable } from '@nestjs/common' +import { Inject, Injectable } from '@nestjs/common' import { QueueEvents } from 'bullmq' import type { Redis } from 'ioredis' import { ConnectionResolver } from './connection-resolver.service' @@ -34,7 +34,7 @@ export class QueueEventsRegistry { private readonly events = new Map() private readonly connections = new Map() - constructor(private readonly connection: ConnectionResolver) {} + constructor(@Inject(ConnectionResolver) private readonly connection: ConnectionResolver) {} /** * Returns the cached `QueueEvents` for `queueName`, creating one on first diff --git a/src/server/services/queue.service.ts b/src/server/services/queue.service.ts index 8aebc68..bb8cfa1 100644 --- a/src/server/services/queue.service.ts +++ b/src/server/services/queue.service.ts @@ -36,7 +36,7 @@ export class QueueService implements OnModuleDestroy { private readonly queues = new Map() constructor( - private readonly connection: ConnectionResolver, + @Inject(ConnectionResolver) private readonly connection: ConnectionResolver, @Inject(BYMAX_QUEUE_RESOLVED_OPTIONS) private readonly options: ResolvedQueueOptions, ) {} diff --git a/src/server/services/worker-registry.service.ts b/src/server/services/worker-registry.service.ts index 5aac130..ff9a77b 100644 --- a/src/server/services/worker-registry.service.ts +++ b/src/server/services/worker-registry.service.ts @@ -99,7 +99,7 @@ export class WorkerRegistry { private readonly entries = new Map() constructor( - private readonly connection: ConnectionResolver, + @Inject(ConnectionResolver) private readonly connection: ConnectionResolver, @Inject(BYMAX_QUEUE_RESOLVED_OPTIONS) private readonly options: ResolvedQueueOptions, ) {}