Skip to content

Commit 0df3380

Browse files
egeominotticlaude
andcommitted
fix(test): close leaked embedded worker in bug-23 (CI unhandled error)
bug-23-scheduler-job-name created a new Worker('test-job-name', {embedded}) inside a Promise executor and never closed it, so it polled for the whole suite. After the 2.8.14 commit added 9 test files, the suite timeline shifted enough that a stray poll coincided with another test's global disk-IO injection: pull -> getSharedManager -> migrate threw SQLITE_IOERR, handlePullError emitted 'error' with no listener -> 'Unhandled error between tests' (exit 1). Capture + await worker.close() to remove the leak. Test-only; no shipped-code change, so still 2.8.14. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 999b6f0 commit 0df3380

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

test/bug-23-scheduler-job-name.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ describe('Bug #23: upsertJobScheduler job.name should use jobTemplate.name', ()
5757
// Wait for the cron to fire
5858
await Bun.sleep(200);
5959

60+
let worker: Worker | undefined;
6061
const receivedName = await new Promise<string>((resolve) => {
61-
const worker = new Worker(
62+
worker = new Worker(
6263
'test-job-name',
6364
async (job) => {
6465
resolve(job.name);
@@ -67,6 +68,11 @@ describe('Bug #23: upsertJobScheduler job.name should use jobTemplate.name', ()
6768
{ embedded: true }
6869
);
6970
});
71+
// Close the worker — otherwise it keeps polling forever (leaked across the
72+
// whole suite) and a stray poll during another test's disk-IO injection
73+
// surfaces as an "Unhandled error between tests" (emit('error') with no
74+
// listener). See CI failure on 2.8.14.
75+
await worker?.close();
7076

7177
expect(receivedName).toBe('send-newsletter');
7278
});

0 commit comments

Comments
 (0)