From 3a88df8d220afaac25131d71ea9a51e80dcf11fe Mon Sep 17 00:00:00 2001 From: Hassieb Pakzad <68423100+hassiebp@users.noreply.github.com> Date: Mon, 3 Feb 2025 13:28:54 +0100 Subject: [PATCH] fix(prompts): handle non-json gateway errors (#503) --- langfuse-core/src/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/langfuse-core/src/index.ts b/langfuse-core/src/index.ts index 8da35f7b..7d331e8d 100644 --- a/langfuse-core/src/index.ts +++ b/langfuse-core/src/index.ts @@ -586,12 +586,12 @@ abstract class LangfuseCoreStateless { } ); - const data = await res.json(); - if (res.status >= 500) { - throw new LangfuseFetchHttpError(res, JSON.stringify(data)); + throw new LangfuseFetchHttpError(res, await res.text()); } + const data = await res.json(); + return { fetchResult: res.status === 200 ? "success" : "failure", data }; }, retryOptions,