fix: settle Pi child capacity reservations
This commit is contained in:
@@ -227,6 +227,33 @@ describe('Pi worker pool', () => {
|
||||
expect(processBudget.activeCount).toBe(0);
|
||||
});
|
||||
|
||||
it('releases the process lease even when stopping an idle worker fails', async () => {
|
||||
const processBudget = new PiProcessBudget(1);
|
||||
const pool = new PiWorkerPool({
|
||||
processBudget,
|
||||
maxIdle: 1,
|
||||
openWorker: async ({ conversation: input }) => {
|
||||
const worker = new FakeWorker(`worker-${input.conversationId}`);
|
||||
worker.stop = async () => {
|
||||
worker.stopped = true;
|
||||
throw new Error('stop failed');
|
||||
};
|
||||
return {
|
||||
worker,
|
||||
session: {
|
||||
piSessionId: `session-${input.conversationId}`,
|
||||
sessionKey: `key-${input.conversationId}`,
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
await pool.prepare(conversation('conversation-stop-failure'));
|
||||
|
||||
await expect(pool.dispose('conversation-stop-failure')).rejects.toThrow('stop failed');
|
||||
expect(processBudget.activeCount).toBe(0);
|
||||
expect(processBudget.waitingCount).toBe(0);
|
||||
});
|
||||
|
||||
it('never evicts a running worker when the warm-idle LRU exceeds its cap', async () => {
|
||||
const workers = new Map<string, FakeWorker>();
|
||||
const pool = new PiWorkerPool({
|
||||
|
||||
Reference in New Issue
Block a user