Skip to content

Commit e21fadf

Browse files
authored
fix(2.0): incomplete chunk header (#2299)
1 parent af827ad commit e21fadf

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

.changeset/loose-stars-greet.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/start": patch
3+
---
4+
5+
fix potentially incomplete first chunk for chunk readers

packages/start/src/fns/serialization.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,14 @@ export class SerovalChunkReader {
167167
}
168168

169169
async next(): Promise<{ done: true; value: undefined } | { done: false; value: string }> {
170-
// Check if the buffer is empty
171-
if (this.buffer.length === 0) {
170+
// Check if the buffer is empty or incomplete
171+
if (this.buffer.length < 12) {
172172
// if we are already done...
173173
if (this.done) {
174+
// incomplete stream
175+
if (this.buffer.length !== 0) {
176+
throw new Error("Malformed server function stream.");
177+
}
174178
return {
175179
done: true,
176180
value: undefined,

0 commit comments

Comments
 (0)