Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions agents/src/ipc/job_proc_lazy_main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ const startJob = (
}, 10000);

try {
const closePromise = once(closeEvent, 'close').then((close) => {
logger.debug('shutting down');
shutdown = true;
safeSend({ case: 'exiting', value: { reason: close[1] } });
});

// Run the job function within the AsyncLocalStorage context
await runWithJobContextAsync(ctx, async () => {
const { tracer, traceTypes } = await import('../telemetry/index.js');
Expand All @@ -138,14 +144,11 @@ const startJob = (
},
{ name: 'job_entrypoint' },
);
}).finally(() => {
}).finally(async () => {
clearTimeout(unconnectedTimeout);
});

await once(closeEvent, 'close').then((close) => {
logger.debug('shutting down');
shutdown = true;
safeSend({ case: 'exiting', value: { reason: close[1] } });
if (!shutdown) {
await closePromise;
}
});
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
Outdated
} catch (error) {
logger.error({ error }, 'error in entry function');
Expand Down
5 changes: 4 additions & 1 deletion agents/src/ipc/proc_pool.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: 2026 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import { Throws } from '@livekit/throws-transformer/throws';
import { describe, expect, it, vi } from 'vitest';
import type { RunningJobInfo } from '../job.js';
import { type JobExecutor, JobStatus } from './job_executor.js';
Expand All @@ -22,7 +23,9 @@ function createMockExecutor() {
}

describe('ProcPool warmed process lock handling', () => {
it('releases lock token from the dequeued warmed process entry', async () => {
it('releases lock token from the dequeued warmed process entry', async (): Promise<
Throws<void, Error>
> => {
const pool = new ProcPool('agent', 1, 1000, 1000, undefined, 0, 0);
const unlock = vi.fn();
const executor = createMockExecutor();
Expand Down
Loading