#discover

9 messages · Page 1 of 1 (latest)

fleet silo
#

The scheduler corn is not working when we have @wet pebbleModel in the constructor. is there a workaround for this?

Error :

[Scheduler] Cannot register cron job "OutboxSchedulerService@retryOutboxPublishing" because it is defined in a non static provider.

@wet pebbleable()
export class EventManagerOutboxService {
constructor(
@wet pebbleModel(OutboxEvent.name)
private outboxEventModel: Model<OutboxEventDocument>
) {}

@Cron(CronExpression.EVERY_10_SECONDS)
async retryOutboxPublishing() {
this.logger.log(
Starting retry outbox events at ${new Date().toISOString()},
);
}

}

supple dirge
#

Is your database module's forRootAsync injectingREQUEST?

fleet silo
#

yes

#

is that the problem

supple dirge
#

Yep

fleet silo
#

MongooseModule.forRootAsync({
imports: [DataVaultManagerModule],
inject: [DataVaultManager],
useClass: MongooseConfigService,
}),

supple dirge
#

Because there's no REQUEST scope tied to the schedule module or service. You need to put that @Cron() in a class that is not REQUEST scoped

fleet silo
#

Thank you. one of you class is using request scope.

haughty cobalt
#

Cannot register cron job "ScheduleTaskService@closeOutdatedNeeds" because it is defined in a non static provider.