Compare commits

...

2 Commits

4 changed files with 15 additions and 3 deletions

View File

@ -1,5 +1,11 @@
# Changelog
## 2024-10-16 - 3.1.7 - fix(VirtualStream)
Fix issue in VirtualStream to handle null values during data writing.
- Ensured writableStream closes gracefully when null values are encountered.
- Added a null check before writing data to the writableStream to prevent errors.
## 2024-10-16 - 3.1.6 - fix(VirtualStream)
Fix backpressure handling in VirtualStream workOnQueue method

View File

@ -1,6 +1,6 @@
{
"name": "@api.global/typedrequest",
"version": "3.1.6",
"version": "3.1.7",
"private": false,
"description": "A TypeScript library for making typed requests towards APIs, including facilities for handling requests, routing, and virtual stream handling.",
"main": "dist_ts/index.js",

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@api.global/typedrequest',
version: '3.1.6',
version: '3.1.7',
description: 'A TypeScript library for making typed requests towards APIs, including facilities for handling requests, routing, and virtual stream handling.'
}

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;
}
}