Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stand-alone CLI script Error on Bootstrap Worker #2852

Open
margamorais opened this issue May 15, 2024 · 1 comment
Open

Stand-alone CLI script Error on Bootstrap Worker #2852

margamorais opened this issue May 15, 2024 · 1 comment
Assignees
Labels
type: bug 🐛 Something isn't working

Comments

@margamorais
Copy link

margamorais commented May 15, 2024

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
@margamorais margamorais added the type: bug 🐛 Something isn't working label May 15, 2024
@michaelbromley
Copy link
Member

Hi,

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants