I want to be able to disable the cron, by setting MY_INTERVAL_IN_MINS env var to 0 or lower.
It worked perfectly fine up to ^4.0.2 a while ago. It now errors in:
error: ┏ A fatal error occured +5ms
error: ┃ [ 1] []
error: ┃ [ 2] {
error: ┃ [ 3] context: undefined,
error: ┃ [ 4] error: CronError: Field (minute) has a step of zero
error: ┃ [ 5] at CronTime._parseField (/home/alfagun74/git/phalcode/gamevault-backend/node_modules/.pnpm/cron@3.1.7/node_modules/cron/dist/time.js:408:27)
error: ┃ [ 6] at CronTime._parse (/home/alfagun74/git/phalcode/gamevault-backend/node_modules/.pnpm/cron@3.1.7/node_modules/cron/dist/time.js:381:18)
error: ┃ [ 7] at new CronTime (/home/alfagun74/git/phalcode/gamevault-backend/node_modules/.pnpm/cron@3.1.7/node_modules/cron/dist/time.js:37:18)
error: ┃ [ 8] at new CronJob (/home/alfagun74/git/phalcode/gamevault-backend/node_modules/.pnpm/cron@3.1.7/node_modules/cron/dist/job.js:25:29)
error: ┃ [ 9] at Function.from (/home/alfagun74/git/phalcode/gamevault-backend/node_modules/.pnpm/cron@3.1.7/node_modules/cron/dist/job.js:55:20)
error: ┃ [10] at /home/alfagun74/git/phalcode/gamevault-backend/node_modules/.pnpm/@nestjs+schedule@4.1.1_@nestjs+common@10.4.6_class-transformer@0.5.1_class-validator@0.14.1_r_vq7ljdie4j2fbguhhtzbswecae/node_modules/@nestjs/schedule/dist/scheduler.orchestrator.js:56:44
error: ┃ [11] at Array.forEach (<anonymous>)
error: ┃ [12] at SchedulerOrchestrator.mountCron (/home/alfagun74/git/phalcode/gamevault-backend/node_modules/.pnpm/@nestjs+schedule@4.1.1_@nestjs+common@10.4.6_class-transformer@0.5.1_class-validator@0.14.1_r_vq7ljdie4j2fbguhhtzbswecae/node_modules/@nestjs/schedule/dist/scheduler.orchestrator.js:54:18)
error: ┃ [13] at SchedulerOrchestrator.onApplicationBootstrap (/home/alfagun74/git/phalcode/gamevault-backend/node_modules/.pnpm/@nestjs+schedule@4.1.1_@nestjs+common@10.4.6_class-transformer@0.5.1_class-validator@0.14.1_r_vq7ljdie4j2fbguhhtzbswecae/node_modules/@nestjs/schedule/dist/scheduler.orchestrator.js:27:14)
error: ┃ [14] at MapIterator.iteratee (/home/alfagun74/git/phalcode/gamevault-backend/node_modules/.pnpm/@nestjs+core@10.4.6_@nestjs+common@10.4.6_class-transformer@0.5.1_class-validator@0.14.1_refl_fnmsffeipfaxcuvrctcpuvhsxa/node_modules/@nestjs/core/hooks/on-app-bootstrap.hook.js:22:43),
error: ┃ [15] timestamp: '2024-10-26T11:40:21.727Z'
error: ┗ [16] }
/home/alfagun74/git/phalcode/gamevault-backend/node_modules/.pnpm/cron@3.1.7/node_modules/cron/dist/time.js:408
throw new errors_1.CronError(`Field (${unit}) has a step of zero`);
^
Error: Field (minute) has a step of zero
at CronTime._parseField (/home/alfagun74/git/phalcode/gamevault-backend/node_modules/.pnpm/cron@3.1.7/node_modules/cron/dist/time.js:408:27)
at CronTime._parse (/home/alfagun74/git/phalcode/gamevault-backend/node_modules/.pnpm/cron@3.1.7/node_modules/cron/dist/time.js:381:18)
at new CronTime (/home/alfagun74/git/phalcode/gamevault-backend/node_modules/.pnpm/cron@3.1.7/node_modules/cron/dist/time.js:37:18)
at new CronJob (/home/alfagun74/git/phalcode/gamevault-backend/node_modules/.pnpm/cron@3.1.7/node_modules/cron/dist/job.js:25:29)
at Function.from (/home/alfagun74/git/phalcode/gamevault-backend/node_modules/.pnpm/cron@3.1.7/node_modules/cron/dist/job.js:55:20)
at /home/alfagun74/git/phalcode/gamevault-backend/node_modules/.pnpm/@nestjs+schedule@4.1.1_@nestjs+common@10.4.6_class-transformer@0.5.1_class-validator@0.14.1_r_vq7ljdie4j2fbguhhtzbswecae/node_modules/@nestjs/schedule/dist/scheduler.orchestrator.js:56:44
at Array.forEach (<anonymous>)
at SchedulerOrchestrator.mountCron (/home/alfagun74/git/phalcode/gamevault-backend/node_modules/.pnpm/@nestjs+schedule@4.1.1_@nestjs+common@10.4.6_class-transformer@0.5.1_class-validator@0.14.1_r_vq7ljdie4j2fbguhhtzbswecae/node_modules/@nestjs/schedule/dist/scheduler.orchestrator.js:54:18)
at SchedulerOrchestrator.onApplicationBootstrap (/home/alfagun74/git/phalcode/gamevault-backend/node_modules/.pnpm/@nestjs+schedule@4.1.1_@nestjs+common@10.4.6_class-transformer@0.5.1_class-validator@0.14.1_r_vq7ljdie4j2fbguhhtzbswecae/node_modules/@nestjs/schedule/dist/scheduler.orchestrator.js:27:14)
at MapIterator.iteratee (/home/alfagun74/git/phalcode/gamevault-backend/node_modules/.pnpm/@nestjs+core@10.4.6_@nestjs+common@10.4.6_class-transformer@0.5.1_class-validator@0.14.1_refl_fnmsffeipfaxcuvrctcpuvhsxa/node_modules/@nestjs/core/hooks/on-app-bootstrap.hook.js:22:43)
Minimum reproduction code
@Cron(`*/0 * * * *`, {
disabled: true
})
Expected behavior
Just dont parse the CRON expression if it is disabled anyway.
Other
For now i have a nasty workaround i would like to not use:
Did you read the migration guide?
Is there an existing issue that is already proposing this?
Potential Commit/PR that introduced the regression
No response
Versions
^4.0.2
->^4.1.1
Describe the regression
I used to use this library like:
I want to be able to disable the cron, by setting
MY_INTERVAL_IN_MINS
env var to0
or lower. It worked perfectly fine up to^4.0.2
a while ago. It now errors in:Minimum reproduction code
Expected behavior
Just dont parse the CRON expression if it is disabled anyway.
Other
For now i have a nasty workaround i would like to not use: