Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logs: limit history count to the retention limit #1914

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/features/device-logs/lib/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { getNanoTimestamp } from '../../../lib/utils.js';
import type { SetupOptions } from '../../../index.js';
import {
LOGS_DEFAULT_HISTORY_COUNT,
LOGS_DEFAULT_RETENTION_LIMIT,
LOGS_DEFAULT_SUBSCRIPTION_COUNT,
LOGS_HEARTBEAT_INTERVAL,
LOGS_READ_STREAM_FLUSH_INTERVAL,
Expand Down Expand Up @@ -202,21 +203,20 @@ function getCount(
countParam: string | undefined,
defaultCount: number,
): number {
let count: number;
if (countParam == null) {
return defaultCount;
}

if (countParam === 'all') {
return Infinity;
}

const parsedCount = parseInt(countParam, 10);

if (!Number.isNaN(parsedCount)) {
return parsedCount;
count = defaultCount;
} else if (countParam === 'all') {
count = Infinity;
} else {
return defaultCount;
const parsedCount = parseInt(countParam, 10);
if (!Number.isNaN(parsedCount)) {
count = parsedCount;
} else {
count = defaultCount;
}
}
return Math.min(count, LOGS_DEFAULT_RETENTION_LIMIT);
}

function getHistory(
Expand Down
Loading