How to disable jsreport correctly?



  • Hi,

    i am using jsreport-core in node.js to develop an application that uses the jsreport-scheduling extension to create schedules that saves/emails the created the reported.
    I want to give the user the option to be able to enable/disable the schedule.
    I am disabling/enabling the schedule by updating the existing schedule in the following manner :-

    jsreport.documentStore.collection("schedules").update(
              { _id: schedule._id },
              {
                $set: {
                  enabled: args.enabled
                }
              });
    

    Now after disabling the schedule by setting enabled: false, whenever i enable it again by enabled: true, the scheduler generates and emails the report multiple times.

    For example - If my scheduler runs every 5 mins and i disable it for 20 mins. Then when i enable it again, it runs 4 times.

    How can i prevent this from happening? I want the scheduler to run only once after i enable it.



  • Hi,
    thanks for reporting this.
    It seems we missed this in the implementation. We will fix it here
    https://github.com/jsreport/jsreport-scheduling/issues/9


  • administrators

    hi @pakhi-newgen can you install the extension using npm i jsreport/jsreport-scheduling and try again? we have done some changes that should prevent this to happen



  • Hey,
    I tried it again by installing using jsreport/jsreport-scheduling, but its still runs pending number of times when i enable it again.


  • administrators

    @pakhi-newgen hmm i tried to reproduce what you describe but i could not find a good way to do it, so if you can provide a github repository with some simplified code that you are using to reproduce this, i can take a look. probably try to change the scheduler to just 1 minute so i can reproduce the example without having to wait too long



  • We have created a sample demo for the issue we are facing on github at : https://github.com/pakhi-newgen/jsreport-scheduling-demo

    The schedule runs every minute and is initially disabled. You will receive a prompt after 3 minutes to enable the schedule. Once you enable the schedule, you will notice that multiple reports are created at that instant.


  • administrators

    hi! sorry for the long wait, i was able to replicate and fix the issue using your repository, can you try re-install again npm i jsreport/jsreport-scheduling and try?



  • Hey! It is fixed now.
    Thanks a lot.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.