Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

chore(datasets): reduce max payload size in csv upload (#5466)

marliessophie778dc24324c4
diff --git a/web/src/features/datasets/components/PreviewCsvImport.tsx b/web/src/features/datasets/components/PreviewCsvImport.tsx
index 1d0b00f8fa..22a9a6c5de 100644
--- a/web/src/features/datasets/components/PreviewCsvImport.tsx
+++ b/web/src/features/datasets/components/PreviewCsvImport.tsx
@@ -25,7 +25,9 @@ import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePos
const MIN_CHUNK_SIZE = 50;
const DELAY_BETWEEN_CHUNKS = 100; // milliseconds
-const MAX_PAYLOAD_SIZE = 1 * 1024 * 1024; // 1MB in bytes
+
+// Max payload size is 1MB, but we must account for any trpc wrapper data and context
+const MAX_PAYLOAD_SIZE = 500 * 1024; // 500KB in bytes
function getOptimalChunkSize(items: any[], startSize: number): number {
const getPayloadSize = (size: number) =>
@@ -37,7 +39,7 @@ function getOptimalChunkSize(items: any[], startSize: number): number {
}),
).length;
- // Binary search for largest chunk size under 1MB
+ // Binary search for largest chunk size under MAX_PAYLOAD_SIZE
let low = MIN_CHUNK_SIZE;
let high = startSize;
let best = MIN_CHUNK_SIZE;