Current Behavior
Using the following configuration results in an error message: schedule rate "cron" not yet supported!
Sample Code
- schedule:
name: Monthly
rate: cron(0 1 10 18 1/1 ? *) # Monthly, the 18th at Midnight UTC-10 (Hawaii)
enabled: true
input:
fequency: 'monthly'
Expected behavior/code
My expectation was that I would not receive an error message.
Environment
serverless version: 1.67.3serverless-offline version: 6.1.4node.js version: 14.0.0OS: macOS 10.15.2Possible Solution
It looks like a solution was commented out in this commit https://github.com/dherault/serverless-offline/commit/1c299846e3d2d963de5f46fbb7340a15055a5740 and the error message was added. I wasn't able to find any context in the issues for why the change was made, the commit message contained no additional information, and there were no code comments to indicate why support was removed.
Additional context/Screenshots
Hi, @dherault 👋 – Can you take a look at this and provide context? Thanks!
@dherault Just a reminder that this one is with you. Looks like this comment was done by @dnalborczyk though.
Is there any info on this by any chance?
For info:
````
works, with the message:
Scheduling [testCronHandler] cron: [*/1 * * * *] input: undefined
but
````
gives the messages
schedule rate "cron" not yet supported!
scheduler: invalid, schedule syntax
Scheduling [testCronHandler] cron: [undefined] input: undefined
I'm assuming because only basic cron syntax is supported ("every X")?
I took a brief look into this so I could carry on. It looks like the schedule code was _influenced_ by the now-unsupported serverless-offline-scheduler plugin, which did support cron.
Looking at the file events/schedule/Schedule.js file, as mentioned by the OP, it looks like the code for corn support was copied over but then commented out for some probably valid reason. Uncommenting it fixed the issue.
I wrote a patch to uncomment cron support, you can find it in the attached zip, just put the patches folder into your project root, install patch-package, and re-install your dependencies.
Warning: Use this patch at your own risk, this code was likely commented out because something is broken, hence why I'm not fixing it with a PR.
serverless-offline-cron-patch.zip
Is there any info on this by any chance?
For info:
- schedule: rate(1 minute)works, with the message:
Scheduling [testCronHandler] cron: [*/1 * * * *] input: undefinedbut
- schedule: cron(0/1 * * * * *)gives the messages
schedule rate "cron" not yet supported! scheduler: invalid, schedule syntax Scheduling [testCronHandler] cron: [undefined] input: undefinedI'm assuming because only basic cron syntax is supported ("every X")?
The same thing is happining to me. Is there any PR to fix this?
I opened this issue coming up on a year ago now. for those running across this issue via Google and such, I don't have any faith that it will ever be addressed. maintainers have not responded to it, so I have to assume they have no interest in it. we have since stopped using serverless and have started using the CDK as a far better alternative.
I opened this issue coming up on a year ago now. for those running across this issue via Google and such, I don't have any faith that it will ever be addressed. maintainers have not responded to it, so I have to assume they have no interest in it. we have since stopped using serverless and have started using the CDK as a far better alternative.
I feel your pain...
How did you implement the offline functionality in CDK?
Any update on this?
Most helpful comment
Is there any info on this by any chance?
For info:
````
````
works, with the message:
Scheduling [testCronHandler] cron: [*/1 * * * *] input: undefinedbut
````
````
gives the messages
schedule rate "cron" not yet supported! scheduler: invalid, schedule syntax Scheduling [testCronHandler] cron: [undefined] input: undefinedI'm assuming because only basic cron syntax is supported ("every X")?