fix(core): Fix the order of operations in SmartDuplex _read method to ensure proper waiting for items.
This commit is contained in:
		| @@ -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. | ||||
|  | ||||
|   | ||||
| @@ -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.' | ||||
| } | ||||
|   | ||||
| @@ -105,11 +105,11 @@ export class SmartDuplex<TInput = any, TOutput = any> extends Duplex { | ||||
|  | ||||
|   public async _read(size: number): Promise<void> { | ||||
|     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(); | ||||
|   | ||||
| @@ -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.' | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user