perf(main): extend launch summary cache window

This commit is contained in:
777genius 2026-05-31 12:57:31 +03:00
parent 9c29b0f8f1
commit 9ffdb6468b
3 changed files with 23 additions and 2 deletions

View file

@ -49,7 +49,7 @@ interface OperationState<T> {
}
export const DEFAULT_LAUNCH_IO_QUIET_WINDOW_MS = 3_000;
export const DEFAULT_LAUNCH_IO_MAX_STALE_AGE_MS = 15_000;
export const DEFAULT_LAUNCH_IO_MAX_STALE_AGE_MS = 120_000;
export const DEFAULT_LAUNCH_IO_STUCK_PRESSURE_MS = 10 * 60_000;
const DEFAULT_WARNING_COOLDOWN_MS = 10_000;

View file

@ -22,7 +22,7 @@ import type {
const logger = createLogger('Service:TeamTaskReader');
const MAX_TASK_FILE_BYTES = 2 * 1024 * 1024;
const ALL_TASKS_CACHE_TTL_MS = 5_000;
const ALL_TASKS_CACHE_TTL_MS = 30_000;
const TASK_FILE_CACHE_MAX_ENTRIES = 8_192;
interface CachedAllTasks {

View file

@ -4,6 +4,7 @@ import {
cloneLaunchIoGovernorPayload,
LaunchIoGovernor,
} from '../../../../src/main/services/team/LaunchIoGovernor';
import type { GlobalTask, TeamProvisioningProgress, TeamSummary } from '../../../../src/shared/types';
function team(teamName: string): TeamSummary {
@ -141,6 +142,26 @@ describe('LaunchIoGovernor', () => {
expect(loadFresh).toHaveBeenCalledTimes(2);
});
it('keeps default launch summary cache through a long active startup', async () => {
let now = 0;
const governor = new LaunchIoGovernor({ now: () => now });
const loadFresh = vi.fn(async () => [task('old-task')]);
await governor.runSummaryOperation('teams:getAllTasks', loadFresh, {
clone: cloneLaunchIoGovernorPayload,
});
now = 60_000;
loadFresh.mockResolvedValue([task('new-task')]);
governor.noteLaunchIntent('team-a', 'launch');
await expect(
governor.runSummaryOperation('teams:getAllTasks', loadFresh, {
clone: cloneLaunchIoGovernorPayload,
})
).resolves.toEqual([task('old-task')]);
expect(loadFresh).toHaveBeenCalledTimes(1);
});
it('does not cache an in-flight result when a dirty generation arrives before it resolves', async () => {
const governor = new LaunchIoGovernor();
const deferred = createDeferred<TeamSummary[]>();