diff --git a/changelog.md b/changelog.md index e072168..b9c431e 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## 2024-10-16 - 3.1.6 - fix(VirtualStream) +Fix backpressure handling in VirtualStream workOnQueue method + +- Resolved an issue in the workOnQueue method of VirtualStream where concurrent execution was not properly managed. +- Introduced a workingDeferred promise to ensure proper queue handling and resolve potential race conditions. + ## 2024-10-16 - 3.1.5 - fix(virtualstream) Add console log for debugging backpressure feedback loop diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 1d892a1..b287c71 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.5', + version: '3.1.6', 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 53cecd8..305b264 100644 --- a/ts/classes.virtualstream.ts +++ b/ts/classes.virtualstream.ts @@ -143,10 +143,17 @@ export class VirtualStream implements plugins.typedRequestInterf constructor() {} + workingDeferred: plugins.smartpromise.Deferred; + /** * takes care of sending */ private async workOnQueue() { + if (this.workingDeferred) { + return this.workingDeferred.promise; + } else { + this.workingDeferred = plugins.smartpromise.defer(); + } if(this.side === 'requesting') { let thisSideIsBackpressured = !this.receiveBackpressuredArray.checkSpaceAvailable(); let otherSideHasNext = false; @@ -219,6 +226,8 @@ export class VirtualStream implements plugins.typedRequestInterf } } + this.workingDeferred.resolve(); + this.workingDeferred = null; } /**