2eb387811d
incremental-sync.ts and api/cw/sync.ts imported getBoss() from workert.ts. When workert.ts (the entry point) dynamically imported incremental-sync.ts, it triggered a circular module re-evaluation that hung indefinitely. Extract the PgBoss singleton and getBoss() factory to a new boss-instance.ts module that neither has top-level async side-effects nor imports from workert.ts. All consumers (workert.ts, index.ts, incremental-sync.ts, cw/sync.ts) now import from boss-instance.ts instead.
23 lines
605 B
TypeScript
23 lines
605 B
TypeScript
import { getBoss } from "../../boss-instance";
|
|
import { WorkerQueue } from "./queues";
|
|
|
|
/**
|
|
* Enqueue a single incremental sync job via PgBoss.
|
|
* Called on an interval from the main API process so it survives worker restarts.
|
|
*/
|
|
export async function enqueueIncrementalSync(): Promise<void> {
|
|
const jobId = await getBoss().send(
|
|
WorkerQueue.DALPURI_INCREMENTAL_SYNC,
|
|
{
|
|
enqueuedAt: new Date().toISOString(),
|
|
},
|
|
{
|
|
singletonKey: "dalpuri-incremental-sync",
|
|
}
|
|
);
|
|
|
|
if (!jobId) {
|
|
console.debug("[interval] DALPURI_INCREMENTAL_SYNC already pending or active");
|
|
}
|
|
}
|