forked from tuvn86/webapp-conversation
fix: log message json pares error
This commit is contained in:
parent
c2d8c9010a
commit
e8294d2e38
1 changed files with 10 additions and 1 deletions
|
|
@ -64,7 +64,16 @@ const handleStream = (response: any, onData: IOnData, onCompleted?: IOnCompleted
|
||||||
lines.forEach((message) => {
|
lines.forEach((message) => {
|
||||||
if (!message || !message.startsWith('data: '))
|
if (!message || !message.startsWith('data: '))
|
||||||
return
|
return
|
||||||
|
try {
|
||||||
bufferObj = JSON.parse(message.substring(6)) // remove data: and parse as json
|
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')
|
if (bufferObj.event !== 'message')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue