Serverless-offline: Schedule rate "cron" not yet supported!

Created on 17 Jul 2020  Â·  8Comments  Â·  Source: dherault/serverless-offline

Bug Report

Current Behavior

Using the following configuration results in an error message: schedule rate "cron" not yet supported!

Sample Code

  • file: serverless.yml
      - 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.3
  • serverless-offline version: 6.1.4
  • node.js version: 14.0.0
  • OS: macOS 10.15.2

Possible 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

Most helpful comment

Is there any info on this by any chance?

For info:

````

  • schedule: rate(1 minute)
    ````

works, with the message:

Scheduling [testCronHandler] cron: [*/1 * * * *] input: undefined

but

````

  • schedule: cron(0/1 * * * * *)
    ````

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")?

All 8 comments

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:

````

  • schedule: rate(1 minute)
    ````

works, with the message:

Scheduling [testCronHandler] cron: [*/1 * * * *] input: undefined

but

````

  • schedule: cron(0/1 * * * * *)
    ````

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: undefined

but

- schedule: cron(0/1 * * * * *)

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")?

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?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mattmeye picture mattmeye  Â·  4Comments

Ali-Dalal picture Ali-Dalal  Â·  4Comments

jormaechea picture jormaechea  Â·  4Comments

JimLynchCodes picture JimLynchCodes  Â·  4Comments

ghost picture ghost  Â·  4Comments