Skip to content

Commit a18c48e

Browse files
committed
Address review feedback
fix: increase handler delay so wip event fires in workId correlation test The wip event is rate-limited to once per 2s and only fires when onFetch processes jobs. With delay(50) the job completes before 2s elapses from manager creation, so emitWip never fires and the test times out. Increase to delay(3000) so the end-of-onFetch emitWip call happens after the 2s threshold. Also resolve handlerCompleted before the delay so it doesn't block the wip assertions.
1 parent 4f49837 commit a18c48e

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

test/workTest.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,14 +333,22 @@ describe('work', function () {
333333

334334
const firstWipEvent = new Promise<Array<any>>(resolve => ctx.boss!.once('wip', resolve))
335335

336+
let handlerCompletedResolve: () => void
337+
const handlerCompleted = new Promise<void>(resolve => { handlerCompletedResolve = resolve })
338+
336339
await ctx.boss.send(ctx.schema)
337340

338-
const workId = await ctx.boss.work(ctx.schema, { localConcurrency: 3, pollingIntervalSeconds: 1 }, () => delay(2000))
341+
const workId = await ctx.boss.work(ctx.schema, { localConcurrency: 3, pollingIntervalSeconds: 1 }, async () => {
342+
handlerCompletedResolve()
343+
await delay(3000)
344+
})
339345

340346
const wip = await firstWipEvent
341347

342348
expect(wip.every((w: any) => w.workId === workId)).toBe(true)
343349
expect(wip.length).toBe(3)
350+
351+
await handlerCompleted
344352
})
345353

346354
it('should reject work() after stopping', async function () {

0 commit comments

Comments
 (0)