fix(quick-260610-i4x-01): replace node-cron schedule() with setInterval in three broker workers
- poller.ts: setInterval(cb, 5 * 60 * 1000) replaces schedule('*/5 * * * *', cb)
- outboxWorker.ts: setInterval(cb, 15 * 1000) replaces schedule('*/15 * * * * *', cb)
- reminderScheduler.ts: setInterval(cb, 60 * 1000) replaces schedule('* * * * *', cb)
- Remove 'import { schedule } from node-cron' from all three files
- Update doc comments to reflect setInterval and document why (node-cron 4.2.1 silent skip)
- Callback bodies and .catch wrappers unchanged; typecheck clean; 91/91 broker tests pass
This commit is contained in:
@@ -17,13 +17,12 @@
|
||||
* T-03-14: create-before-delete ordering; create-fail aborts delete.
|
||||
*
|
||||
* runOutboxDrain is exported for unit testing.
|
||||
* startOutboxWorker wraps it in a 15-second node-cron schedule.
|
||||
* startOutboxWorker wraps it in a 15-second setInterval.
|
||||
* (node-cron 4.2.1 silently skipped scheduled executions in the long-running server process;
|
||||
* setInterval fires reliably in the same process — replaced to fix the silent skip.)
|
||||
*
|
||||
* Source: poller.ts pattern (runPoll/startBrokerPoller)
|
||||
* Source: https://github.com/node-cron/node-cron (v4 stable)
|
||||
*/
|
||||
|
||||
import { schedule } from 'node-cron'
|
||||
import { z } from 'zod'
|
||||
import { and, eq, lte } from 'drizzle-orm'
|
||||
import { db } from '../db/client.js'
|
||||
@@ -752,11 +751,13 @@ export async function runOutboxDrain(): Promise<void> {
|
||||
/**
|
||||
* Starts the 15-second background outbox drain schedule.
|
||||
* Call once at API startup (wired in index.ts beside startBrokerPoller).
|
||||
* Uses setInterval instead of node-cron: node-cron 4.2.1 silently skipped executions
|
||||
* in the long-running server process; setInterval fires reliably.
|
||||
*/
|
||||
export function startOutboxWorker(): void {
|
||||
schedule('*/15 * * * * *', () => {
|
||||
setInterval(() => {
|
||||
runOutboxDrain().catch((err: unknown) => {
|
||||
console.error('[outboxWorker] Unhandled runOutboxDrain error:', err)
|
||||
})
|
||||
})
|
||||
}, 15 * 1000)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user