From 526c96e8a2af1e4abc8b2869b14e8bf453878ff7 Mon Sep 17 00:00:00 2001 From: Ben White Date: Mon, 29 Jul 2024 18:31:35 +0200 Subject: [PATCH] fix(cdp): Handle if there are no logs (#24053) --- plugin-server/src/cdp/utils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugin-server/src/cdp/utils.ts b/plugin-server/src/cdp/utils.ts index 9c94987a409..cc49b63fc1e 100644 --- a/plugin-server/src/cdp/utils.ts +++ b/plugin-server/src/cdp/utils.ts @@ -170,6 +170,10 @@ export const prepareLogEntriesForClickhouse = ( const sortedLogs = logs.sort((a, b) => a.timestamp.toMillis() - b.timestamp.toMillis()) + if (sortedLogs.length === 0) { + return [] + } + // Start with a timestamp that is guaranteed to be before the first log entry let previousTimestamp = sortedLogs[0].timestamp.minus(1)