vendure-ecommerce/vendure

Stand-alone CLI script Error on Bootstrap Worker

margamorais opened this issue · 2 comments

Here's an improved version of the issue description:

Describe the bug

We followed the steps in the Vendure documentation to create a standalone script, which we were able to run successfully through the command-line interface. However, when we tried to run the same script as a cron job, we encountered several issues related to the Vendure Worker.

The script we created modifies products by creating and updating them. However, when we ran it through the cron job, it created several jobs and we started receiving error messages, such as:

[worker] error 5/15/24, 6:33 PM - [Vendure Worker] Job queue "send-email" encountered an error (set log level to Debug for trace): "No metadata for \"JobRecord\" was found."

Our second issue is that we want to apply a buffer to all these jobs. We were able to do this for the search by calling the index only at the end of the script and setting bufferUpdates to true in the Elastic search plugin. However, we are not sure how to apply the same buffer to these jobs. Again. if we run this through the CLI, it doesn't attempt to create all these jobs, or at least there are no errors such as these.

The cron job plugin created consists in two files:

cron.plugin.ts

import { ScheduleModule } from '@nestjs/schedule';
import { ImportProductsCronJob } from './services/cron-import-products.service';
import { TypeOrmHealthIndicator } from '@nestjs/terminus';

@Module({
    imports: [ScheduleModule.forRoot()],
    providers: [ImportProductsCronJob, TypeOrmHealthIndicator],
    // compatibility: '^2.0.0',
})
export class CronJobPlugin {}

cron-import-products.service.ts

@Injectable()
export class ImportProductsCronJob {
    @Cron(CronExpression.EVERY_HOUR)
    async handleCron() {
        console.log('Cron job is running!');
        // Implement your cron job logic here
        await getProductCount();
        console.log('DONE');
    }
}

Environment

@vendure/core version: 2.2.2
Nodejs version: v22.1.0
Database: Postgres

Config

  • Using the default job queue plugin

Hi,

Can you provide a minimal reproduction of the issue(s)?

The issue was not solved, however this use case doesn't apply to our project anymore. Therefore I'm going to close the issue for now, if we encounter the error again or in another case we will reopen it. Thank you.