🛌 test: Poll Instead of Sleeping for Dead Subagent Owner Expiry (#16144)

Co-authored-by: Lia <lia@librechat.ai>
This commit is contained in:
lia-by-librechat[bot] 2026-09-20 20:20:09 -04:00 • committed by GitHub
parent 7dc745a95b
commit a2a5ff708a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -549,9 +549,24 @@ describe('RedisSubagentTaskControlTransport', () => {
await liveOwner.registerTask('scope-1', liveTask.taskId, 20);
await deadOwner.destroy();
await new Promise<void>((resolve) => setTimeout(resolve, 35));
await expect(requester.list('scope-1')).resolves.toEqual([liveTask]);
/** The dead owner's entry lapses on its own TTL while the live owner's heartbeat
* re-registers its entry against that same TTL, so a runner that stalls past 20ms
* can find both gone for one beat. Poll until the directory settles rather than
* asserting on a single sleep. */
let listed: SubagentTaskSnapshot[] = [];
for (let attempt = 0; attempt < 100 && listed.length === 0; attempt += 1) {
await new Promise<void>((resolve) => setTimeout(resolve, 5));
try {
listed = await requester.list('scope-1');
} catch (error) {
/** The dead owner is still registered, so the request routes to a process that
* answers nothing. Anything else is a real failure. */
if (!(error instanceof SubagentTaskOwnerUnavailableError)) {
throw error;
}
}
}
expect(listed).toEqual([liveTask]);
await Promise.all([liveOwner.destroy(), requester.destroy()]);
});