denoland / deploy_feedback

For reporting issues with Deno Deploy
https://deno.com/deploy
74 stars 5 forks source link

Unable to modify cron schedule without redeploying #714

Open tomblixt opened 2 weeks ago

tomblixt commented 2 weeks ago

What problem are you trying to solve?

I am working on a project where I would like to use the Deno Cron functionality, but I encountered a limitation. You cannot modify or stop a cron job once it has been set. There may be a way to do this, but I couldn't figure it out.

Describe the solution you'd like

It would be really useful if you could at least stop a cron job, allowing you to create a new one. I have two examples here of how this could look like.

Example 1

const task = Deno.cron("Cron job", "*/30 * * * * *", () => { ... });
task.stop()

Example 2

const task = Deno.stopCron("Cron job")

Describe alternatives you've considered

I tried changing the schedule by setting one with the same name, but then resulted in this error: Uncaught TypeError: Cron with this name already exists. I will also be checking out Croner to see if it gets the job done for me.

Deno.cron("Cron job", "*/30 * * * * *", () => {
  console.log("Cron job ran, every 30 seconds");
});

const changeCron = () => {
  Deno.cron("Cron job, "*/45 * * * *", () => {
    console.log("Cron job ran, every 45 seconds");
  });
};

Documentation, Adoption, Migration Strategy

No response