[P2] CronScheduler setTimeout overflow fires monthly/yearly jobs immediately in a tight loop

Open Beginner friendly
#14 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
typescript
Domain
desktop

Research direction

Start in apps/desktop/src/main/cron.ts around lines 95-115 and inspect how CronScheduler calculates delays and reschedules jobs. Verify the timeout delay is bounded for monthly and yearly schedules, and that a capped timeout does not execute the job until Date.now() reaches nextTs; confirm the tight loop is eliminated.

Written by the indexing model from the issue text.

Description

bug

Priority: P2
File: apps/desktop/src/main/cron.ts lines ~95-115

JS setTimeout fires immediately when delay > 2^31-1 ms (~24.8 days). Monthly (~30d) and yearly (~365d) cron jobs exceed this limit, causing them to fire immediately and re-schedule in a tight loop.

Fix: Cap delay at Math.min(delay, 2**31-1); when the cap fires, re-check Date.now() >= nextTs before executing the job.

Dominant language
TypeScript
Stars
120
Forks
13
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from unbug/tday

All issues in unbug/tday

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.