diff --git a/changelog.md b/changelog.md index b9c431e..e2be463 100644 --- a/changelog.md +++ b/changelog.md @@ -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 diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index b287c71..e6d696a 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -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.' } diff --git a/ts/classes.virtualstream.ts b/ts/classes.virtualstream.ts index 305b264..4a73a2c 100644 --- a/ts/classes.virtualstream.ts +++ b/ts/classes.virtualstream.ts @@ -399,11 +399,17 @@ export class VirtualStream implements plugins.typedRequestInterf public async writeToWebstream(writableStreamArg: WritableStream) { 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; } }