Skip to content

Conversation

@cmraible
Copy link
Contributor

@cmraible cmraible commented Nov 26, 2025

The job manager has one fatal flaw: it's not possible to schedule a recurring job that runs in the main thread; only in a worker thread.

In Ghost we've hacked around this by scheduling a worker job, then emitting an event back to the main thread to trigger a job to execute. This works, but it's essentially a really convoluted and expensive setTimeout()...why not just use a setTimeout()?

This spike rips out breejs entirely, and uses node-cron to handle the scheduling bits. This way we can just pass a function to addJob() and it will run on the provided schedule in the main thread, without having to spawn a worker.

This does mean we no longer support running jobs in worker threads at all, which we'll probably need to solve. There's nothing stopping us from launching a worker within the function we pass to node-cron, or even pass it to a pool of workers to handle.

@cmraible cmraible changed the title Spike: breeejs out, node-cron in Spike: job manager: breeejs out, node-cron in Nov 26, 2025
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.

2 participants