Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schedule fails to compile when using cron: "* * * * *" #2849

Closed
skyrpex opened this issue Jun 8, 2023 · 11 comments · Fixed by #5870 or #5956
Closed

Schedule fails to compile when using cron: "* * * * *" #2849

skyrpex opened this issue Jun 8, 2023 · 11 comments · Fixed by #5870 or #5956
Assignees
Labels
🐛 bug Something isn't working 🛠️ compiler Compiler 🎨 sdk SDK

Comments

@skyrpex
Copy link
Contributor

skyrpex commented Jun 8, 2023

I tried this:

wing compile cron.w -t sim                     
// cron.w
bring cloud;
bring redis;

let cronSchedule = new cloud.Schedule(cloud.ScheduleProps{
  cron: "* * * * *"
}) as "Cron Schedule";

cronSchedule.onTick(inflight () => {
  log("Cron schedule ticked!");
});

This happened:

Error: ERROR: cannot use * in both the Day-of-month and Day-of-week fields. If you use it in one, you must use ? in the other

demo/target/index.wsim.294604.tmp/.wing/preflight.js:513
       );
       (rateSchedule.onTick(new $Closure8(this,"$Closure8")));
>>     const cronSchedule = this.node.root.newAbstract("@winglang/sdk.cloud.Schedule",this,"Cron Schedule",{
       "cron": "* * * * *",}
       );

I expected this:

It should compile and the scheduler should tick every minute.

Is there a workaround?

I don't know.

Component

Compiler, SDK

Wing Version

0.19.4

Wing Console Version

No response

Node.js Version

18.16.0

Platform(s)

MacOS

Anything else?

No response

Community Notes

  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.
@skyrpex skyrpex added the 🐛 bug Something isn't working label Jun 8, 2023
@monadabot monadabot added this to Wing Jun 8, 2023
@github-project-automation github-project-automation bot moved this to 🆕 New - not properly defined in Wing Jun 8, 2023
@staycoolcall911
Copy link
Contributor

@skyrpex this is by design - @tsuf239 fixed added this in response to a Terraform error in #2744.
You can see the error message (perhaps it should be improved?) and just change your cron expression to * * * * ?

@skyrpex
Copy link
Contributor Author

skyrpex commented Jun 8, 2023

Oh, my knowledge on cron syntax is quite lacking but when I have to work with it I use https://crontab.guru. The website says * * * * * is valid but * * * * ? isn't.

So I guess there are different syntaxes 🤔

@skyrpex skyrpex closed this as completed Jun 8, 2023
@github-project-automation github-project-automation bot moved this from 🆕 New - not properly defined to ✅ Done in Wing Jun 8, 2023
@staycoolcall911
Copy link
Contributor

staycoolcall911 commented Jun 8, 2023

Thanks @skyrpex - I'll make sure to discuss it with @tsuf239

@Chriscbr
Copy link
Contributor

Chriscbr commented Jun 8, 2023

Reopening since I also just ran into this issue. I believe it's a bug since "?" is not a standard part of the unix cron format (not mentioned on the link shared by @skyrpex, and on the wikipedia page here it's listed as a non-standard character).

One of the design tenets of our standard library is for APIs to be agnostic to the target cloud. If AWS has a unique format, the implementation for the AWS target can convert the cron string into a format that AWS supports. Nitric provides a nice example of how they handle this: https://nitric.io/docs/schedules#using-cron

@Chriscbr Chriscbr reopened this Jun 8, 2023
@github-project-automation github-project-automation bot moved this from ✅ Done to 🤝 Backlog - handoff to owners in Wing Jun 8, 2023
@github-actions
Copy link

github-actions bot commented Aug 8, 2023

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days.
Feel free to re-open this issue when there's an update or relevant information to be added.
Thanks!

@github-actions github-actions bot added the Stale label Aug 8, 2023
@ekeren
Copy link

ekeren commented Aug 8, 2023 via email

@github-actions github-actions bot removed the Stale label Aug 9, 2023
@github-actions
Copy link

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days.
Feel free to re-open this issue when there's an update or relevant information to be added.
Thanks!

@github-actions github-actions bot added the Stale label Oct 14, 2023
@marciocadev marciocadev self-assigned this Mar 9, 2024
@mergify mergify bot closed this as completed in #5870 Mar 16, 2024
mergify bot pushed a commit that referenced this issue Mar 16, 2024
Some characters like `?` are configurations used by AWS, but to make the schedule more cloud-agnostic, I made some changes to bring it closer to the Unix implementation

Now a cron like `* * * * *` will not throw an exception.

Closes #2849 

## Checklist

- [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted)
- [x] Description explains motivation and solution
- [x] Tests added (always)
- [ ] Docs updated (only required for features)
- [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing

*By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
@github-project-automation github-project-automation bot moved this from 🤝 Backlog - handoff to owners to ✅ Done in Wing Mar 16, 2024
@monadabot
Copy link
Contributor

Congrats! 🚀 This was released in Wing 0.61.8.

@github-project-automation github-project-automation bot moved this from ✅ Done to 🤝 Backlog - handoff to owners in Wing Mar 16, 2024
@staycoolcall911
Copy link
Contributor

Reopening, since this was reverted in #5953

@staycoolcall911
Copy link
Contributor

Related discussion on Slack:
https://winglang.slack.com/archives/C048QCN2XLJ/p1710573042627429

@mergify mergify bot closed this as completed in #5956 Mar 18, 2024
@github-project-automation github-project-automation bot moved this from 🤝 Backlog - handoff to owners to ✅ Done in Wing Mar 18, 2024
mergify bot pushed a commit that referenced this issue Mar 18, 2024
…5956)

Some characters like `?` are configurations used by AWS, but to make the schedule more cloud-agnostic, I made some changes to bring it closer to the Unix implementation

Now a cron like `* * * * *` will not throw an exception.

I removed this test because it no longer made sense.
```wing
try {
      new cloud.Schedule( cron: "* * * * *" ) as "s5";
} catch e {
      error = e;
}
assert(error == "cannot use * in both the Day-of-month and Day-of-week fields. If you use it in one, you must use ? in the other");
```

Closes #2849

## Checklist

- [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted)
- [x] Description explains motivation and solution
- [x] Tests added (always)
- [ ] Docs updated (only required for features)
- [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing

*By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
@monadabot
Copy link
Contributor

Congrats! 🚀 This was released in Wing 0.61.14.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 🛠️ compiler Compiler 🎨 sdk SDK
Projects
Archived in project
6 participants