Skip to content

Commit

Permalink
fix: support long lines (#484)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArturSharapov authored Dec 27, 2024
1 parent ad96f2c commit a151dfc
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions protocol/deno_streams/reply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,23 @@ async function tryReadErrorReply(reader: BufReader): Promise<never> {
}

async function readLine(reader: BufReader): Promise<Uint8Array> {
const result = await reader.readLine();
let result = await reader.readLine();
if (result == null) {
throw new InvalidStateError();
}

const { line } = result;
let line = result.line;

while (result?.more) {
result = await reader.readLine();
if (result == null) {
throw new InvalidStateError();
}
const mergedLine = new Uint8Array(line.length + result.line.length);
mergedLine.set(line);
mergedLine.set(result.line, line.length);
line = mergedLine;
}
return line;
}

Expand Down

0 comments on commit a151dfc

Please sign in to comment.