Skip to content

Commit 25da090

Browse files
committed
fix: support long lines
1 parent ad96f2c commit 25da090

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

protocol/deno_streams/reply.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,23 @@ async function tryReadErrorReply(reader: BufReader): Promise<never> {
131131
}
132132

133133
async function readLine(reader: BufReader): Promise<Uint8Array> {
134-
const result = await reader.readLine();
134+
let result = await reader.readLine();
135135
if (result == null) {
136136
throw new InvalidStateError();
137137
}
138138

139-
const { line } = result;
139+
let line = result.line;
140+
141+
while (result?.more) {
142+
result = await reader.readLine();
143+
if (result == null) {
144+
throw new InvalidStateError();
145+
}
146+
const mergedLine = new Uint8Array(line.length + result.line.length);
147+
mergedLine.set(line);
148+
mergedLine.set(result.line, line.length);
149+
line = mergedLine;
150+
}
140151
return line;
141152
}
142153

0 commit comments

Comments
 (0)