langfuse-core
Advanced tools
Comparing version 3.20.1-alpha.8 to 3.20.1-alpha.9
@@ -329,4 +329,10 @@ 'use strict'; | ||
} | ||
function isLangfuseFetchHttpError(error) { | ||
return typeof error === "object" && error.name === "LangfuseFetchHttpError"; | ||
} | ||
function isLangfuseFetchNetworkError(error) { | ||
return typeof error === "object" && error.name === "LangfuseFetchNetworkError"; | ||
} | ||
function isLangfuseFetchError(err) { | ||
return typeof err === "object" && (err.name === "LangfuseFetchHttpError" || err.name === "LangfuseFetchNetworkError"); | ||
return isLangfuseFetchHttpError(err) || isLangfuseFetchNetworkError(err); | ||
} | ||
@@ -356,12 +362,11 @@ // Constants for URLs | ||
} | ||
function isErrorWithResponse(error) { | ||
return error instanceof Error && "response" in error && error.response !== null && typeof error.response === "object" && "status" in error.response; | ||
} | ||
function logIngestionError(error) { | ||
if (isErrorWithResponse(error)) { | ||
if (isLangfuseFetchHttpError(error)) { | ||
const code = error.response.status; | ||
const errorResponse = getErrorResponseByCode(code); | ||
console.error("Error while flushing Langfuse.", errorResponse); | ||
console.error("[Langfuse SDK] Error while flushing Langfuse.", errorResponse, `Error details: ${error}`); | ||
} else if (isLangfuseFetchNetworkError(error)) { | ||
console.error("[Langfuse SDK] Network error while flushing Langfuse.", `Error details: ${error}`); | ||
} else { | ||
console.error("Unknown error while flushing Langfuse.", error); | ||
console.error("[Langfuse SDK] Unknown error while flushing Langfuse.", `Error details: ${error}`); | ||
} | ||
@@ -724,3 +729,3 @@ } | ||
} catch (e) { | ||
console.error(`Event Body for ${type} is not JSON-serializable: ${e}`); | ||
console.error(`[Langfuse SDK] Event Body for ${type} is not JSON-serializable: ${e}`); | ||
this._events.emit("error", `Event Body for ${type} is not JSON-serializable: ${e}`); | ||
@@ -771,3 +776,3 @@ return; | ||
} catch (e) { | ||
console.error("Error while flushing Langfuse", e); | ||
console.error("[Langfuse SDK] Error while flushing Langfuse", e); | ||
} | ||
@@ -815,5 +820,3 @@ }); | ||
}); | ||
const requestPromise = this.fetchWithRetry(url, fetchOptions) | ||
// TODO: 207, replicate python SDK implementation in giving back errors to users | ||
.then(() => done()).catch(err => { | ||
const requestPromise = this.fetchWithRetry(url, fetchOptions).then(() => done()).catch(err => { | ||
done(err); | ||
@@ -850,3 +853,3 @@ }); | ||
} catch (error) { | ||
console.error(error); | ||
console.error(`[Langfuse SDK] ${error}`); | ||
remainingItems.push(...queue.slice(i)); | ||
@@ -911,3 +914,2 @@ break; | ||
// fetch will only throw on network errors or on timeouts | ||
console.log("Error while fetching Langfuse", e); | ||
throw new LangfuseFetchNetworkError(e); | ||
@@ -939,3 +941,3 @@ } | ||
} catch (e) { | ||
console.error("Error while shutting down Langfuse", e); | ||
console.error("[Langfuse SDK] Error while shutting down Langfuse", e); | ||
} | ||
@@ -1217,3 +1219,3 @@ } | ||
} catch (error) { | ||
console.error(`Error while fetching prompt '${cacheKey}':`, error); | ||
console.error(`[Langfuse SDK] Error while fetching prompt '${cacheKey}':`, error); | ||
throw error; | ||
@@ -1220,0 +1222,0 @@ } |
{ | ||
"name": "langfuse-core", | ||
"version": "3.20.1-alpha.8", | ||
"version": "3.20.1-alpha.9", | ||
"engines": { | ||
@@ -40,3 +40,3 @@ "node": ">=18" | ||
}, | ||
"gitHead": "c0bfdf498576bdeee31a9d6fb1f6336c6db3c530" | ||
"gitHead": "d885ab3ee75c4eba3b57cdd67fb5682a85996cf6" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
585679
6569