Skip to content
This repository has been archived by the owner on Aug 28, 2020. It is now read-only.

Scheduled task not behaving as expected #303

Closed
1 of 2 tasks
ImUrX opened this issue May 12, 2018 · 2 comments · Fixed by #309
Closed
1 of 2 tasks

Scheduled task not behaving as expected #303

ImUrX opened this issue May 12, 2018 · 2 comments · Fixed by #309
Assignees
Labels
Bug: Confirmed Issues that report confirmed bugs. Priority: Low Issues that must be fixed or PRs that must be finished and merged with low priority. SEM: Patch PRs that contain bugfixes and should be released in the next patch version. Type: Maintenance Issues and PRs related to the maintenance of a module.

Comments

@ImUrX
Copy link
Contributor

ImUrX commented May 12, 2018

Describe the issue

I got multiple recurring tasks that should ran every minute but what happens is that the first task runs then the second ones run in the second minute and in the third minute the third tasks runs, and a loop starts.

Code or steps to reproduce

Make multiple recurring tasks (mine hapened with the same task) with the cron "* * * * *" (that means that they should run every minute of every hour of every day, etc), after that check how the multiple recurring tasks are executing, for example if you want to do a simple test you could make a task that does console.log("test"), and that should appear n times (n being the amount of recurring tasks you made) in the console but it doesnt.

Expected an actual behaviour

What should happen is that your console should be filled of "test" but it is not because only one scheduledTask was ran.

Further details

  • discord.js version: 12.0.0dev
  • node.js version: 8.11.1
  • Klasa version: 0.5.0dev
  • I have modified core files.
  • I have tested the issue on latest master. Commit hash: c6be589
@ImUrX
Copy link
Contributor Author

ImUrX commented May 12, 2018

The Task:

const { Task } = require("klasa");

module.exports = class extends Task {

    async run() {
        this.client.emit("log", "test");
    }

};

The code I made for running the task:
Klasa.Schedule.create(nameOfTask, "* * * * *")

@bdistin
Copy link
Contributor

bdistin commented May 14, 2018

I have identified the cause of this. There was intentionally a patch made to prevent long-running tasks from starting every minute until the original Task#run() had completed. Unfortunately, that limited only one of any specific task to be run in the same minute. (you could have an unlimited number of unique tasks, but only one of each in a single minute)

I think I have a proper fix in mind for this so that both task behaviors act as expected.

@bdistin bdistin self-assigned this May 14, 2018
@bdistin bdistin added Bug: Confirmed Issues that report confirmed bugs. Type: Maintenance Issues and PRs related to the maintenance of a module. SEM: Patch PRs that contain bugfixes and should be released in the next patch version. Priority: Low Issues that must be fixed or PRs that must be finished and merged with low priority. labels May 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug: Confirmed Issues that report confirmed bugs. Priority: Low Issues that must be fixed or PRs that must be finished and merged with low priority. SEM: Patch PRs that contain bugfixes and should be released in the next patch version. Type: Maintenance Issues and PRs related to the maintenance of a module.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants