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

Every X seconds cron fails with maximum call stack exceeded #260

Closed
fschaeffler opened this issue Oct 3, 2024 · 5 comments
Closed

Every X seconds cron fails with maximum call stack exceeded #260

fschaeffler opened this issue Oct 3, 2024 · 5 comments

Comments

@fschaeffler
Copy link

Describe the bug
When defining a cron for every X seconds, I get an exception with maximum call stack exceeded.

To Reproduce

  1. install croner
  2. require croner
  3. create a cron which should trigger every X seconds

Example:

const { Cron } = require('croner')

// works as expected
new Cron('* * * * * *', () => console.log('test every second'))

// fails with maximum call stack exceeded
new Cron('/3 * * * * *', () => console.log('test 3 seconds'))

Uncaught RangeError: Maximum call stack size exceeded
    at CronDate.findNext (/home/flo/dev/private/trading/autotrader/node_modules/croner/dist/croner.min.cjs:1:15327)
    at CronDate.recurse (/home/flo/dev/private/trading/autotrader/node_modules/croner/dist/croner.min.cjs:1:16435)
    at CronDate.recurse (/home/flo/dev/private/trading/autotrader/node_modules/croner/dist/croner.min.cjs:1:16993)
    at CronDate.recurse (/home/flo/dev/private/trading/autotrader/node_modules/croner/dist/croner.min.cjs:1:16993)
    at CronDate.recurse (/home/flo/dev/private/trading/autotrader/node_modules/croner/dist/croner.min.cjs:1:16993)
    at CronDate.recurse (/home/flo/dev/private/trading/autotrader/node_modules/croner/dist/croner.min.cjs:1:16791)
    at CronDate.recurse (/home/flo/dev/private/trading/autotrader/node_modules/croner/dist/croner.min.cjs:1:16993)
    at CronDate.recurse (/home/flo/dev/private/trading/autotrader/node_modules/croner/dist/croner.min.cjs:1:16993)
    at CronDate.recurse (/home/flo/dev/private/trading/autotrader/node_modules/croner/dist/croner.min.cjs:1:16993)
    at CronDate.recurse (/home/flo/dev/private/trading/autotrader/node_modules/croner/dist/croner.min.cjs:1:16993)

Expected behavior
There's no exception when creating this cron and it gets triggered every X seconds.

System:

  • OS: Linux (Linux 6.8.0-45-generic #45-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 30 12:02:04 UTC 2024 x86_64 GNU/Linux)
  • Runtime: Node.js
  • Version: 18.20.4
  • croner: 8.1.2
@fschaeffler fschaeffler added the bug label Oct 3, 2024
@Hexagon
Copy link
Owner

Hexagon commented Oct 3, 2024

Interesting! What if you add a * before /3, like */3 * * * * *?

@Hexagon
Copy link
Owner

Hexagon commented Oct 3, 2024

Should work, but leave this open. I need to fiure out if it should be handled as a syntax error, or "just work". Call stack is not expexted behavior!

@fschaeffler
Copy link
Author

fschaeffler commented Oct 3, 2024

You're totally right. Adding an asterisk before it solves the issue. Thank you for looking into it!

@Hexagon
Copy link
Owner

Hexagon commented Oct 3, 2024

Resolved in dev channel, version 9.0.0-dev.4, by making the asterisk before / explicitly optional. Install using npm install croner@dev

@Hexagon Hexagon added this to the 9.0 milestone Oct 3, 2024
@Hexagon Hexagon mentioned this issue Oct 9, 2024
@Hexagon
Copy link
Owner

Hexagon commented Oct 15, 2024

Now fixed in stable channel, through [email protected]

@Hexagon Hexagon closed this as completed Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants