denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
94.66k stars 5.25k forks source link

Invalid cron name #21402

Closed sant123 closed 10 months ago

sant123 commented 10 months ago

Version: Deno 1.38.3

Hi, when creating a Cron with special characters the following error is thrown:

image

Is this expected?

Thanks!

silva4dev commented 10 months ago

@sant123 Well, I looked at the latest version of deno_cron, in the first parameter you will provide the time and second the callback that will execute the action.

Link to Documentation

Example:

import { cron } from 'https://deno.land/x/deno_cron/cron.ts'

cron('*/1 * * * *', () => {
  console.log('Testing cron @', new Date())
})

Obs: You are unable to enter the cron name

sant123 commented 10 months ago

I'm talking about Deno.cron() from Deno API not deno_cron from third party.

This code using Deno.cron works fine:

Deno.cron("Testing cron", "*/1 * * * *", () => {
  console.log("Executed!", new Date());
});
justjavac commented 10 months ago

https://github.com/denoland/deno/blob/5f6181df4a914c0d05ea3d2b63190b9ee2d764ca/ext/cron/lib.rs#L118-L128

sant123 commented 10 months ago

The code above makes sense, thank you both!