Giter Club home page Giter Club logo

Comments (14)

f1sle avatar f1sle commented on May 15, 2024 1

Okay, thank you for your time.
I'll check that for sure.
Seems like it's a bug of another system :)

from croner.

ObaidAshiq avatar ObaidAshiq commented on May 15, 2024 1

Could it be because u had earlier installed node- cron and then u installed cronner
I am having similar issue

from croner.

Hexagon avatar Hexagon commented on May 15, 2024

Interesting! Could you please do a console.log beside checkForNewReviews, like

() => {
   console.log(new Date().getTime());
   checkForNewReviews();
}

To get a better view of whats going on?

from croner.

f1sle avatar f1sle commented on May 15, 2024

Here you are:
1641157690002
1641157690005
[2022-01-02 13:08:13.541] http: POST /api/reviews/update (3514 ms) 200
[2022-01-02 13:08:14.974] http: POST /api/reviews/update (4917 ms) 200
1641157750000
1641157750000
[2022-01-02 13:09:14.773] http: POST /api/reviews/update (4765 ms) 200
[2022-01-02 13:09:17.014] http: POST /api/reviews/update (7003 ms) 200
1641157810001
1641157810001
[2022-01-02 13:10:15.568] http: POST /api/reviews/update (5560 ms) 200
[2022-01-02 13:10:32.324] http: POST /api/reviews/update (22312 ms) 200
Also a question, does it supposed to run it every 10 seconds? ('10 * * * * *')

from croner.

Hexagon avatar Hexagon commented on May 15, 2024

Seems like you accidentally trigger the scheduling twice, maybe by including the triggering file twice? Croner really should not be able to make duplicate runs like that :)

Yes, if you use six part notation (10 * * * * *) the first part sets seconds, if you use five parts (10 * * * *) the first part sets minutes.

Edit: If you pass { maxRuns: 1 } as the second parameter to Cron, and your function as third parameter, do it run once or twice?

Edit2: If you make a console.log(new Date().getTime() just before Cron(...), do you see the log once or twice?

from croner.

f1sle avatar f1sle commented on May 15, 2024

I have already tried three different cron packages (croner, node-cron, node-scheduler), the same problem exists for all of them.

from croner.

f1sle avatar f1sle commented on May 15, 2024

So, with this configuration it runs every minute ('10 * * * * *').
This is really strange.

This is the exact output I got with console.log(new Date().getTime():

1641158410001
1641158410001
[2022-01-02 13:20:13.783] http: POST /api/reviews/update (3758 ms) 200
[2022-01-02 13:20:14.496] http: POST /api/reviews/update (4440 ms) 200
1641158470002
1641158470001
[2022-01-02 13:21:14.936] http: POST /api/reviews/update (4927 ms) 200
[2022-01-02 13:21:15.658] http: POST /api/reviews/update (5646 ms) 200

I removed all the cache and still the problem exists.

from croner.

Hexagon avatar Hexagon commented on May 15, 2024

See my edited comments for pointers, your pattern is supposed to run at "second 10" once every minute, */10 * * * * * would run every tenth second

from croner.

Hexagon avatar Hexagon commented on May 15, 2024

Did the output of your last comments come from putting console.log outside the triggered function? Like

console.log(new Date...);
const job = Cron(...);

from croner.

f1sle avatar f1sle commented on May 15, 2024

Nope, this is my exact code:

const checkForNewReviews = require("./functions/checkForNewReviews");

var Cron = require("croner");

const job = Cron("*/10 * * * * *", () => {
  console.log(new Date().getTime());
});

PS: now it runs every 10 seconds, but still got console.log(date) duplicates.

from croner.

Hexagon avatar Hexagon commented on May 15, 2024

Can you try this instead

const checkForNewReviews = require("./functions/checkForNewReviews");

var Cron = require("croner");

console.log(new Date().getTime());

const job = Cron("*/10 * * * * *", () => {});

And see if you get a duplicate log?

from croner.

f1sle avatar f1sle commented on May 15, 2024

image

image

from croner.

Hexagon avatar Hexagon commented on May 15, 2024

Ah, the code in backend/config/cron.js is run twice, for some reason

from croner.

Hexagon avatar Hexagon commented on May 15, 2024

No problem!

from croner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.