fix(team): guard runtime process row cache invalidation
This commit is contained in:
parent
b688800d57
commit
a7a732e226
2 changed files with 12 additions and 2 deletions
|
|
@ -25932,7 +25932,12 @@ export class TeamProvisioningService {
|
||||||
): { rows: RuntimeTelemetryProcessTableRow[] | null } | null {
|
): { rows: RuntimeTelemetryProcessTableRow[] | null } | null {
|
||||||
const cached = this.runtimeProcessRowsForUsageSnapshotByTeam.get(teamName);
|
const cached = this.runtimeProcessRowsForUsageSnapshotByTeam.get(teamName);
|
||||||
const nowMs = Date.now();
|
const nowMs = Date.now();
|
||||||
if (!cached || cached.expiresAtMs <= nowMs || cached.runId !== runId) {
|
if (
|
||||||
|
!cached ||
|
||||||
|
cached.expiresAtMs <= nowMs ||
|
||||||
|
cached.runId !== runId ||
|
||||||
|
cached.generation !== this.getRuntimeSnapshotCacheGeneration(teamName)
|
||||||
|
) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3514,7 +3514,7 @@ describe('TeamProvisioningService', () => {
|
||||||
expect(listRuntimeProcessTableForCurrentPlatform).toHaveBeenCalledTimes(2);
|
expect(listRuntimeProcessTableForCurrentPlatform).toHaveBeenCalledTimes(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('keeps the short live runtime metadata cache for tracked runs', async () => {
|
it('reuses process rows through the short liveness cache for tracked runs', async () => {
|
||||||
vi.useFakeTimers();
|
vi.useFakeTimers();
|
||||||
vi.setSystemTime(new Date('2026-05-03T12:00:00.000Z'));
|
vi.setSystemTime(new Date('2026-05-03T12:00:00.000Z'));
|
||||||
const svc = new TeamProvisioningService();
|
const svc = new TeamProvisioningService();
|
||||||
|
|
@ -3533,6 +3533,11 @@ describe('TeamProvisioningService', () => {
|
||||||
vi.setSystemTime(new Date('2026-05-03T12:00:03.000Z'));
|
vi.setSystemTime(new Date('2026-05-03T12:00:03.000Z'));
|
||||||
await (svc as any).getLiveTeamAgentRuntimeMetadata('runtime-team');
|
await (svc as any).getLiveTeamAgentRuntimeMetadata('runtime-team');
|
||||||
|
|
||||||
|
expect(listRuntimeProcessTableForCurrentPlatform).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
|
vi.setSystemTime(new Date('2026-05-03T12:00:06.000Z'));
|
||||||
|
await (svc as any).getLiveTeamAgentRuntimeMetadata('runtime-team');
|
||||||
|
|
||||||
expect(listRuntimeProcessTableForCurrentPlatform).toHaveBeenCalledTimes(2);
|
expect(listRuntimeProcessTableForCurrentPlatform).toHaveBeenCalledTimes(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue