JSON Parsing bug in codebase indexing handle data #4932
Labels
area:indexing
Relates to embedding and indexing
kind:bug
Indicates an unexpected problem or unintended behavior
"needs-triage"
Before submitting your bug report
Relevant environment info
Description
When testing the codebase features, I found that the indexing process was stuck.
Finally, I found that the error occurred in this code:
binary\src\TcpMessenger.ts
(also same logic is inbinary\src\IpcMessenger.ts
)_handleLine
function, caught the following error message:According to the logic of the
_handleLine
function, it converts line to a JSON object and reads the value of messageType.The error message SyntaxError: Unexpected non-whitespace character after JSON indicates:
The JSON parser successfully parsed a complete JSON object,But after the 512th character, a non-whitespace character was found
This is probably because the two JSON objects are directly connected:
`{... the first JSON ends}{ the second JSON begins...}``
To check the upstream logic, in the
_handleData
function, thedata
parameter is converted to a string and then split. The code usesd.split(/\r\n/)
to split the message, but the error message indicates that there may be multiple JSON objects directly connected in the actual received data without line breaks.I don't know why the source code always assumes that JSON messages are always separated by \r\n, but from the error message I got, the
_handleData
function may mistakenly assign multiple Json data to the lines variable.chatGPT's suggested enhance code to ensure split json not only separated by \r\n
FYI
The text was updated successfully, but these errors were encountered: