Commit e8294d2e authored by Joel's avatar Joel

fix: log message json pares error

parent c2d8c901
......@@ -64,7 +64,16 @@ const handleStream = (response: any, onData: IOnData, onCompleted?: IOnCompleted
lines.forEach((message) => {
if (!message || !message.startsWith('data: '))
return
try {
bufferObj = JSON.parse(message.substring(6)) // remove data: and parse as json
} catch (e) {
// mute handle message cut off
onData('', isFirstMessage, {
conversationId: bufferObj?.conversation_id,
messageId: bufferObj?.id,
})
return
}
if (bufferObj.event !== 'message')
return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment