From 40e8e06ff186e7caf9a334bbd54b6c7a0c081aa1 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Wed, 16 Oct 2024 01:54:39 +0200 Subject: [PATCH] fix(core): Fix the order of operations in SmartDuplex _read method to ensure proper waiting for items. --- changelog.md | 6 ++++++ ts/00_commitinfo_data.ts | 2 +- ts/smartstream.classes.smartduplex.ts | 4 ++-- ts_web/00_commitinfo_data.ts | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index 4537fdd..be8f558 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## 2024-10-16 - 3.2.1 - fix(core) +Fix the order of operations in SmartDuplex _read method to ensure proper waiting for items. + +- Adjusted the order of reading function execution and waiting for items in the SmartDuplex _read method. +- Fixed potential issues with stream data processing timing. + ## 2024-10-16 - 3.2.0 - feat(SmartDuplex) Added method to create SmartDuplex from a WebReadableStream. diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index ad47881..418649c 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartstream', - version: '3.2.0', + version: '3.2.1', description: 'A library to simplify the creation and manipulation of Node.js streams, providing utilities for handling transform, duplex, and readable/writable streams effectively in TypeScript.' } diff --git a/ts/smartstream.classes.smartduplex.ts b/ts/smartstream.classes.smartduplex.ts index e344234..e6b5d67 100644 --- a/ts/smartstream.classes.smartduplex.ts +++ b/ts/smartstream.classes.smartduplex.ts @@ -105,11 +105,11 @@ export class SmartDuplex extends Duplex { public async _read(size: number): Promise { this.debugLog(`${this.options.name}: read was called`); - await this.backpressuredArray.waitForItems(); - this.debugLog(`${this.options.name}: successfully waited for items.`); if (this.options.readFunction) { await this.options.readFunction(); } + await this.backpressuredArray.waitForItems(); + this.debugLog(`${this.options.name}: successfully waited for items.`); let canPushMore = true; while (this.backpressuredArray.data.length > 0 && canPushMore) { const nextChunk = this.backpressuredArray.shift(); diff --git a/ts_web/00_commitinfo_data.ts b/ts_web/00_commitinfo_data.ts index ad47881..418649c 100644 --- a/ts_web/00_commitinfo_data.ts +++ b/ts_web/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartstream', - version: '3.2.0', + version: '3.2.1', description: 'A library to simplify the creation and manipulation of Node.js streams, providing utilities for handling transform, duplex, and readable/writable streams effectively in TypeScript.' }