Skip to content

fix: cron unhandled promises - #302

Closed
aadityakumarsah wants to merge 4 commits into
modelence:mainfrom
aadityakumarsah:fix/cron-unhandled-promises
Closed

aadityakumarsah wants to merge 4 commits into
modelence:mainfrom
aadityakumarsah:fix/cron-unhandled-promises

Conversation

@aadityakumarsah

@aadityakumarsah aadityakumarsah commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #303

This PR addresses two interconnected issues within the packages/modelence/src/cron/jobs.ts file:

  1. Unhandled Promises / Race Conditions: Replaced the forEach(async ...) loop inside tickCronJobs with an await Promise.all(...) wrapper mapped over the object values. This ensures that the interval correctly awaits the completion of all concurrently scheduled cron jobs for the current tick, properly trapping any rejections that might otherwise crash the process and preventing runaway job accumulations.
  2. Loop Optimization: Replaced synchronous .forEach calls in startCronJobs with standard for...of loops, avoiding unnecessary callback closure allocations.

Testing:

  • Existing unit tests for cron jobs and timing pass successfully.
  • Linters run successfully without errors.

@omegascorp

Copy link
Copy Markdown
Collaborator

@aadityakumarsah this seems to contain changes from another PR, though it will likely be resolved automatically when the other PR is merged

@omegascorp omegascorp changed the title Fix/cron unhandled promises fix: cron unhandled promises Aug 10, 2026
@omegascorp

Copy link
Copy Markdown
Collaborator

Thanks for this, and sorry for the slow response. Closing — the socket.io fix and React import removals landed in #299, and the branch is conflicting now. On the cron change, see #303: that rejection path is already guarded.

Your instinct pointed at something real one line up though — opened #338 for it. A small PR against fresh main touching only jobs.ts would be welcome.

The dependency cleanup looks fine as its own PR, minus the root package-lock.json (looks accidental).

@omegascorp omegascorp closed this Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix unhandled promise rejections and optimize array iterations in cron jobs

2 participants