fix(VirtualStream): Fix issue in VirtualStream to handle null values during data writing.

This commit is contained in:
2024-10-16 02:47:35 +02:00
parent 11c6559e33
commit 050966cd6f
3 changed files with 14 additions and 2 deletions

View File

@@ -399,11 +399,17 @@ export class VirtualStream<T = Uint8Array> implements plugins.typedRequestInterf
public async writeToWebstream(writableStreamArg: WritableStream<T>) {
const writer = writableStreamArg.getWriter();
while(this.keepAlive || this.receiveBackpressuredArray.checkHasItems()) {
await writer.write(await this.fetchData());
const value = await this.fetchData();
if (value === null) {
writableStreamArg.close();
break;
}
await writer.write(value);
}
}
public async close() {
this.sendData(null);
this.keepAlive = false;
}
}