fix: use full intervals content in worker cache key, not just length

Two different interval sets with the same length would produce
the same cache key, returning stale results. Serialize each
interval's startedAt~completedAt into the key.
This commit is contained in:
Artem Rootman 2026-04-05 18:09:59 +00:00
parent 270eb547cb
commit bc7981f6b9
No known key found for this signature in database
GPG key ID: B7C30676209A822C

View file

@ -44,7 +44,10 @@ parentPort?.on('message', async (msg: TeamDataWorkerRequest) => {
}
case 'findLogsForTask': {
const { teamName, taskId, options } = msg.payload;
const cacheKey = `${teamName}:${taskId}:${options?.owner ?? ''}:${options?.status ?? ''}:${options?.since ?? ''}:${options?.intervals?.length ?? 0}`;
const intervalsKey = options?.intervals
? options.intervals.map((i) => `${i.startedAt}~${i.completedAt ?? ''}`).join(',')
: '';
const cacheKey = `${teamName}:${taskId}:${options?.owner ?? ''}:${options?.status ?? ''}:${options?.since ?? ''}:${intervalsKey}`;
// Check result cache
const cached = logsResultCache.get(cacheKey);