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

Dynamic cron job not wokring #27

Closed
sandeepsuvit opened this issue Jun 27, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@sandeepsuvit
Copy link
Contributor

commented Jun 27, 2019

Hi, i was trying to create a scheduler using dynamic cron job like so when my module initialises

@Injectable()
export class NotificationsService implements OnModuleInit {
    constructor(
        @InjectSchedule() private readonly schedule: Schedule,
    ) { }

    onModuleInit() {
        // Trigger every 10 seconds
        this.schedule.scheduleCronJob('cron', '*/10 * * * * *', () => {
            console.log('executing my custom interval job');
            return false;
        });
    }
}

When i start the server i get this error in the console

(node:45897) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'startTime' of undefined

which is weird because as per the method params the startTime and endTime are optional

scheduleCronJob(key: string, cron: string, callback: JobCallback, config?: ICronJobConfig): void;
...
export interface ICronJobConfig extends IJobConfig {
    startTime?: Date;
    endTime?: Date;
}

Am i missing something here?

@issue-label-bot

This comment has been minimized.

Copy link

commented Jun 27, 2019

Issue Label Bot is not confident enough to auto-label this issue. See dashboard for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.