Skip to content

[BUG] - Strapi cron missing rule option #19710

@antokhio

Description

@antokhio

Bug report

Strapi documantation states that cron task should be:

module.exports = () => ({
  bootstrap({ strapi }) {
    strapi.cron.add({
      myJob: {
        task: ({ strapi }) => {
          console.log("hello from plugin");
        },
        options: {  
          rule: "* * * * * *",  // << Notice that `options` has an attribute `rule`
        },
      },
    });
  },
});

however

type Task = TaskFn | {
    task: TaskFn;
    options: string;  // Notice `options` is a string
};

Does not have rule, which results to task isn't being created

Required System information

  • Node.js version: v18.18.2
  • NPM version: 8.13.1
  • Strapi version: 4.17.1
  • Database: Postgres
  • Operating system: Windows
  • Is your project Javascript or Typescript: Typescript

Describe the bug

The full description coming from strapi/documentation#1954

Steps to reproduce the behavior

  1. Create new strapi
  2. Add cron task to bootstrap based on documentation
  3. Notice task never fires

Expected behavior

Task created with:

module.exports = () => ({
  bootstrap({ strapi }) {
    strapi.cron.add({
      myJob: {
        task: ({ strapi }) => {
          console.log("hello from plugin");
        },
        options: {  
          rule: "* * * * * *",  // << Notice that `options` has an attribute `rule`
        },
      },
    });
  },
});

Would console.log every minute.

Additional context

strapi/documentation#1954

Metadata

Metadata

Assignees

Labels

issue: bugIssue reporting a bugseverity: mediumIf it breaks the basic use of the product but can be worked aroundsource: typescriptSource is related to TypeScript (typings, tooling, ...)status: confirmedConfirmed by a Strapi Team member or multiple community members

Type

No type

Projects

Status

Fixed/Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions