Skip to content

Commit

Permalink
fix: chunk parsing error
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonghakseo committed Feb 6, 2024
1 parent 2468aad commit e894009
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/pages/background/lib/infra/chatGPT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ async function parseResult(

let result = "";
while (reader) {
const { value, done } = await reader.read();
const { value: _value, done } = await reader.read();
const value = (_value as string).trim();
if (done) {
break;
}
Expand All @@ -125,7 +126,8 @@ async function parseResult(
const parseToJSON = (line: string) => {
try {
return JSON.parse(line);
} catch {
} catch (e) {
console.error(e);
return;
}
};
Expand Down

0 comments on commit e894009

Please sign in to comment.