From a7dd637691be9dc5ebbf2ac3c81d72a49ee47d95 Mon Sep 17 00:00:00 2001 From: plettj Date: Wed, 3 Dec 2025 23:49:08 -0800 Subject: [PATCH] fix: Don't require a space after `data:` when processing SSE events --- sdks/typescript/packages/client/src/transform/sse.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sdks/typescript/packages/client/src/transform/sse.ts b/sdks/typescript/packages/client/src/transform/sse.ts index 07809d7c4..a5e355021 100644 --- a/sdks/typescript/packages/client/src/transform/sse.ts +++ b/sdks/typescript/packages/client/src/transform/sse.ts @@ -52,7 +52,10 @@ export const parseSSEStream = (source$: Observable): Observable /** * Helper function to process an SSE event. * Extracts and joins data lines, then parses the result as JSON. - * Follows the SSE spec by only processing 'data:' prefixed lines. + * + * Follows the SSE spec by processing lines starting with 'data:', + * ignoring a single space if it is present after the colon. + * * @param eventText The raw event text to process */ function processSSEEvent(eventText: string) { @@ -60,9 +63,9 @@ export const parseSSEStream = (source$: Observable): Observable const dataLines: string[] = []; for (const line of lines) { - if (line.startsWith("data: ")) { - // Extract data content (remove 'data: ' prefix) - dataLines.push(line.slice(6)); + if (line.startsWith("data:")) { + // Remove 'data:' prefix, and optionally a single space afterwards + dataLines.push(line.slice(5).replace(/^ /, "")); } }