Search code examples
node.jsnode-cron

node-cron - Deprecation warning: imediateStart is deprecated and will be removed


I updated nodejs from 8 to 10.12 and receive that warning message.

D:\BitBucket\EA Studio>node index
DEPRECIATION: imediateStart is deprecated and will be removed soon in favor of the options param.
...

package.json

{
  "dependencies": {
    ...
    "node-cron": "^2.0.3",
}

Usage:

"use strict";

const cron = require("node-cron");
cron.schedule("5 * * * *", () => null, false);

Any solutions?

Since I don't use imediateStart in my code, the warning origin must be within the internal code of the node-cron. Do the developers made that to not forget to update their own code? how much better would be to show: "This version of node-cron uses deprecated code. Please update it to version xxx as soon as it is released".


Solution

  • Just replace

    cron.schedule("5 * * * *", () => null, false);
    

    with

    cron.schedule("5 * * * *", () => null, {scheduled:false});
    

    From node-cron documentation on schedule method:

    options Object: Optional configuration for job scheduling.

    Options

    scheduled: A boolean to set if the created task is schaduled. Default true;

    timezone: The timezone that is used for job scheduling;