mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-30 19:59:40 +02:00
fix(react): output non-abort errors in console, handle bogus message type (#3524)
This commit is contained in:
@@ -62,6 +62,14 @@ class MessageTupleManager {
|
||||
}
|
||||
|
||||
add(serialized: Message): string | null {
|
||||
// TODO: this is sometimes sent from the API
|
||||
// figure out how to prevent this or move this to LC.js
|
||||
if (serialized.type.endsWith("MessageChunk")) {
|
||||
serialized.type = serialized.type
|
||||
.slice(0, -"MessageChunk".length)
|
||||
.toLowerCase() as Message["type"];
|
||||
}
|
||||
|
||||
const chunk = convertToChunk(coerceMessageLikeToMessage(serialized));
|
||||
|
||||
const id = chunk.id;
|
||||
@@ -772,6 +780,7 @@ export function useStream<
|
||||
(error.name === "AbortError" || error.name === "TimeoutError")
|
||||
)
|
||||
) {
|
||||
console.error(error);
|
||||
setStreamError(error);
|
||||
onError?.(error);
|
||||
}
|
||||
@@ -785,7 +794,7 @@ export function useStream<
|
||||
}
|
||||
};
|
||||
|
||||
const error = isLoading ? streamError : historyError;
|
||||
const error = streamError ?? historyError;
|
||||
const values = streamValues ?? historyValues;
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user