mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-10-22 01:53:33 +00:00
⏱️ test: Size the Subagent Lease TTL Above Shard Jitter (#15568)
The child-thread heartbeat fences itself when a renewal commits at or after the deadline it was issued against, so a 500ms lease made this test's window narrower than the scheduling stalls a loaded coverage shard produces: an ordinary pause read as a lapse, the post-preparation gate refused the run, and the assertion saw the provider never invoked while the lease row was still held. Give the lease two seconds so the heartbeat, not the runner, decides. Take the slow-preparation warning by its own delay as well, instead of assuming it is the last timer scheduled before the test resumes.
This commit is contained in:
parent
32e8724193
commit
a9ce3d2b33
1 changed files with 9 additions and 3 deletions
|
|
@ -1224,7 +1224,12 @@ describe('SubagentThreadTaskStore', () => {
|
|||
return methods.getMessages(...args);
|
||||
}),
|
||||
};
|
||||
const options = { leaseTtlMs: 500, leaseHeartbeatMs: 50 };
|
||||
/** The heartbeat fences itself when a renewal commits after the deadline it was
|
||||
* issued against, so the TTL is this test's tolerance for runner jitter, not just
|
||||
* its pace. Keep it well above the scheduling stalls a loaded shard produces: a
|
||||
* half-second lease turns an ordinary pause into a lapse and the prepared run is
|
||||
* refused instead of executed. */
|
||||
const options = { leaseTtlMs: 2_000, leaseHeartbeatMs: 50 };
|
||||
const firstWorker = new SubagentThreadTaskStore(slowMethods, options);
|
||||
const secondWorker = new SubagentThreadTaskStore(methods, options);
|
||||
const config = buildSubagentThreadTaskConfig(firstWorker, { userId, parentConversationId });
|
||||
|
|
@ -1250,8 +1255,9 @@ describe('SubagentThreadTaskStore', () => {
|
|||
const heartbeatIndex =
|
||||
heartbeatCall == null ? -1 : intervalSpy.mock.calls.indexOf(heartbeatCall);
|
||||
const heartbeat = intervalSpy.mock.results[heartbeatIndex]?.value as NodeJS.Timeout | undefined;
|
||||
const warningIndex = timeoutSpy.mock.calls.length - 1;
|
||||
expect(timeoutSpy.mock.calls[warningIndex]?.[1]).toBe(5_000);
|
||||
const warningCall = [...timeoutSpy.mock.calls].reverse().find(([, delay]) => delay === 5_000);
|
||||
const warningIndex = warningCall == null ? -1 : timeoutSpy.mock.calls.lastIndexOf(warningCall);
|
||||
expect(warningCall?.[1]).toBe(5_000);
|
||||
const warning = timeoutSpy.mock.results[warningIndex]?.value as NodeJS.Timeout | undefined;
|
||||
expect(heartbeat?.hasRef()).toBe(true);
|
||||
expect(warning?.hasRef()).toBe(true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue